~~~
func byte2string2(in [16]byte) []byte {
tmp := make([]byte, 16)
for i, value := range in {
tmp[i] = value
}
return tmp
}
~~~
还有更快的方法吗???
我知道了
参考:https://segmentfault.com/a/1190000005006351
~~~
func byte2string2(in [16]byte) []byte {
tmp := make([]byte, 0)
x := (*[3]uintptr)(unsafe.Pointer(&tmp))
x[0] = uintptr(unsafe.Pointer(&in))
x[1] = 16
x[2] = 16
return tmp
}
~~~
#1