blob: c9868aac2b484cbdab23bb08b346ebf572c78c3c [file] [log] [blame]
Joey Armstronga6af1522023-01-17 16:06:16 -05001// +build !appengine
2
3package util
4
5import (
6 "unsafe"
7)
8
9// BytesToString converts byte slice to string.
10func BytesToString(b []byte) string {
11 return *(*string)(unsafe.Pointer(&b))
12}
13
14// StringToBytes converts string to byte slice.
15func StringToBytes(s string) []byte {
16 return *(*[]byte)(unsafe.Pointer(
17 &struct {
18 string
19 Cap int
20 }{s, len(s)},
21 ))
22}