| Abhay Kumar | 40252eb | 2025-10-13 13:25:53 +0000 | [diff] [blame^] | 1 | //go:build !appengine |
| serkant.uluderya | e5afeff | 2021-02-23 18:00:23 +0300 | [diff] [blame] | 2 | // +build !appengine |
| 3 | |||||
| 4 | package internal | ||||
| 5 | |||||
| 6 | import "unsafe" | ||||
| 7 | |||||
| 8 | // String converts byte slice to string. | ||||
| 9 | func String(b []byte) string { | ||||
| 10 | return *(*string)(unsafe.Pointer(&b)) | ||||
| 11 | } | ||||
| 12 | |||||
| 13 | // Bytes converts string to byte slice. | ||||
| 14 | func Bytes(s string) []byte { | ||||
| 15 | return *(*[]byte)(unsafe.Pointer( | ||||
| 16 | &struct { | ||||
| 17 | string | ||||
| 18 | Cap int | ||||
| 19 | }{s, len(s)}, | ||||
| 20 | )) | ||||
| 21 | } | ||||