mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-24 12:46:38 +00:00
19 lines
445 B
Go
19 lines
445 B
Go
|
//go:build !appengine && !js && go1.21
|
||
|
// +build !appengine,!js,go1.21
|
||
|
|
||
|
package util
|
||
|
|
||
|
import (
|
||
|
"unsafe"
|
||
|
)
|
||
|
|
||
|
// BytesToReadOnlyString returns a string converted from given bytes.
|
||
|
func BytesToReadOnlyString(b []byte) string {
|
||
|
return unsafe.String(unsafe.SliceData(b), len(b))
|
||
|
}
|
||
|
|
||
|
// StringToReadOnlyBytes returns bytes converted from given string.
|
||
|
func StringToReadOnlyBytes(s string) []byte {
|
||
|
return unsafe.Slice(unsafe.StringData(s), len(s))
|
||
|
}
|