StringToBytes converts string to byte slice without a memory allocation. For more details, see https://github.com/golang/go/issues/53003#issuecomment-1140276077.
(s string)
| 11 | // StringToBytes converts string to byte slice without a memory allocation. |
| 12 | // For more details, see https://github.com/golang/go/issues/53003#issuecomment-1140276077. |
| 13 | func StringToBytes(s string) []byte { |
| 14 | return unsafe.Slice(unsafe.StringData(s), len(s)) |
| 15 | } |
| 16 | |
| 17 | // BytesToString converts byte slice to string without a memory allocation. |
| 18 | // For more details, see https://github.com/golang/go/issues/53003#issuecomment-1140276077. |
no outgoing calls