2024-11-08 14:51:23 +01:00
|
|
|
//go:build !appengine
|
2021-08-25 15:34:33 +02:00
|
|
|
// +build !appengine
|
|
|
|
|
|
|
|
package internal
|
|
|
|
|
|
|
|
import "unsafe"
|
|
|
|
|
|
|
|
// String converts byte slice to string.
|
|
|
|
func String(b []byte) string {
|
2024-11-08 14:51:23 +01:00
|
|
|
if len(b) == 0 {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return unsafe.String(&b[0], len(b))
|
2021-08-25 15:34:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bytes converts string to byte slice.
|
|
|
|
func Bytes(s string) []byte {
|
2024-11-08 14:51:23 +01:00
|
|
|
if s == "" {
|
|
|
|
return []byte{}
|
|
|
|
}
|
|
|
|
return unsafe.Slice(unsafe.StringData(s), len(s))
|
2021-08-25 15:34:33 +02:00
|
|
|
}
|