本站源代码
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.

19 lines
290B

  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. }
上海开阖软件有限公司 沪ICP备12045867号-1