You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
290 B

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