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.

22 lines
353 B

  1. //go:build !appengine
  2. // +build !appengine
  3. package internal
  4. import "unsafe"
  5. // String converts byte slice to string.
  6. func String(b []byte) string {
  7. return *(*string)(unsafe.Pointer(&b))
  8. }
  9. // Bytes converts string to byte slice.
  10. func Bytes(s string) []byte {
  11. return *(*[]byte)(unsafe.Pointer(
  12. &struct {
  13. string
  14. Cap int
  15. }{s, len(s)},
  16. ))
  17. }