mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-23 20:26:39 +00:00
be3b8076ca
Bumps [github.com/yuin/goldmark](https://github.com/yuin/goldmark) from 1.7.4 to 1.7.6. - [Release notes](https://github.com/yuin/goldmark/releases) - [Commits](https://github.com/yuin/goldmark/compare/v1.7.4...v1.7.6) --- updated-dependencies: - dependency-name: github.com/yuin/goldmark dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
25 lines
563 B
Go
25 lines
563 B
Go
//go:build !appengine && !js && !go1.21
|
|
// +build !appengine,!js,!go1.21
|
|
|
|
package util
|
|
|
|
import (
|
|
"reflect"
|
|
"unsafe"
|
|
)
|
|
|
|
// BytesToReadOnlyString returns a string converted from given bytes.
|
|
func BytesToReadOnlyString(b []byte) string {
|
|
return *(*string)(unsafe.Pointer(&b))
|
|
}
|
|
|
|
// StringToReadOnlyBytes returns bytes converted from given string.
|
|
func StringToReadOnlyBytes(s string) (bs []byte) {
|
|
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
|
|
bh := (*reflect.SliceHeader)(unsafe.Pointer(&bs))
|
|
bh.Data = sh.Data
|
|
bh.Cap = sh.Len
|
|
bh.Len = sh.Len
|
|
return
|
|
}
|