Skip to content

Instantly share code, notes, and snippets.

@dgryski
Created June 26, 2016 18:23
Show Gist options
  • Save dgryski/65d632958e4d88c7f79aaa7e1d2b10c0 to your computer and use it in GitHub Desktop.
Save dgryski/65d632958e4d88c7f79aaa7e1d2b10c0 to your computer and use it in GitHub Desktop.
// +build !appengine
package mpchash
import (
"reflect"
"unsafe"
)
func stringToSlice(s string) []byte {
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
bh := &reflect.SliceHeader{
Data: sh.Data,
Len: sh.Len,
Cap: sh.Len,
}
bp := (*[]byte)(unsafe.Pointer(bh))
return *bp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment