unsafe.go (331B)
1 // +build !appengine 2 3 package internal 4 5 import "unsafe" 6 7 // String converts byte slice to string. 8 func String(b []byte) string { 9 return *(*string)(unsafe.Pointer(&b)) 10 } 11 12 // Bytes converts string to byte slice. 13 func Bytes(s string) []byte { 14 return *(*[]byte)(unsafe.Pointer( 15 &struct { 16 string 17 Cap int 18 }{s, len(s)}, 19 )) 20 }