redis/unsafe.go

15 lines
286 B
Go
Raw Normal View History

// +build !appengine
package redis
2015-09-04 13:30:37 +03:00
import (
"reflect"
"unsafe"
)
func bytesToString(b []byte) string {
2015-09-04 13:30:37 +03:00
bytesHeader := (*reflect.SliceHeader)(unsafe.Pointer(&b))
strHeader := reflect.StringHeader{bytesHeader.Data, bytesHeader.Len}
return *(*string)(unsafe.Pointer(&strHeader))
}