1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// +build !appengine package fwd import ( "reflect" "unsafe" ) // unsafe cast string as []byte func unsafestr(b string) []byte { l := len(b) return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ Len: l, Cap: l, Data: (*reflect.StringHeader)(unsafe.Pointer(&b)).Data, })) }