I want to assign string to bytes array:
var arr [20]byte str := \"abc\" for k, v := range []byte(str) { arr[k] = byte(v) }
Have another m
Besides the methods mentioned above, you can also do a trick as
s := "hello" b := *(*[]byte)(unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&s))))
Go Play: http://play.golang.org/p/xASsiSpQmC
You should never use this :-)