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