【发布时间】:2015-06-04 11:06:28
【问题描述】:
我有这个代码:
hashChannel <- []byte(md5.Sum(buffer.Bytes()))
我得到这个错误:
cannot convert md5.Sum(buffer.Bytes()) (type [16]byte) to type []byte
即使没有显式转换,这也不起作用。我也可以保留 [16]byte 类型,但有时我需要转换它,因为我通过 TCP 连接发送它:
_, _ = conn.Write(h)
转换它的最佳方法是什么? 谢谢
【问题讨论】:
-
[:]将数组转换为切片