2017-01-13 14:39:59 +03:00
|
|
|
// +build !appengine
|
|
|
|
|
|
|
|
package internal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2018-01-11 11:07:24 +03:00
|
|
|
// BytesToString converts byte slice to string.
|
2017-01-13 14:39:59 +03:00
|
|
|
func BytesToString(b []byte) string {
|
2018-01-11 11:07:24 +03:00
|
|
|
return *(*string)(unsafe.Pointer(&b))
|
2017-01-13 14:39:59 +03:00
|
|
|
}
|
2017-06-02 16:19:43 +03:00
|
|
|
|
2018-01-11 11:07:24 +03:00
|
|
|
// StringToBytes converts string to byte slice.
|
2017-06-02 16:19:43 +03:00
|
|
|
func StringToBytes(s string) []byte {
|
2018-01-11 11:07:24 +03:00
|
|
|
return *(*[]byte)(unsafe.Pointer(
|
|
|
|
&struct {
|
|
|
|
string
|
|
|
|
Cap int
|
|
|
|
}{s,len(s)},
|
|
|
|
))
|
2017-06-02 16:19:43 +03:00
|
|
|
}
|