diff options
author | 2024-11-08 13:51:23 +0000 | |
---|---|---|
committer | 2024-11-08 13:51:23 +0000 | |
commit | 29007b1b886e7455ece5aa6e4d477805209fad88 (patch) | |
tree | 21b11cbf12faf71d44d43c61a2d4916b7bd82b80 /vendor/github.com/uptrace/bun/internal/unsafe.go | |
parent | bump ncruces/go-sqlite3 to v0.20.2 (#3524) (diff) | |
download | gotosocial-29007b1b886e7455ece5aa6e4d477805209fad88.tar.xz |
[chore] update bun libraries to v1.2.5 (#3528)
* update bun libraries to v1.2.5
* pin old v1.29.0 of otel
Diffstat (limited to 'vendor/github.com/uptrace/bun/internal/unsafe.go')
-rw-r--r-- | vendor/github.com/uptrace/bun/internal/unsafe.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/vendor/github.com/uptrace/bun/internal/unsafe.go b/vendor/github.com/uptrace/bun/internal/unsafe.go index 4bc79701f..1a0331297 100644 --- a/vendor/github.com/uptrace/bun/internal/unsafe.go +++ b/vendor/github.com/uptrace/bun/internal/unsafe.go @@ -1,3 +1,4 @@ +//go:build !appengine // +build !appengine package internal @@ -6,15 +7,16 @@ import "unsafe" // String converts byte slice to string. func String(b []byte) string { - return *(*string)(unsafe.Pointer(&b)) + if len(b) == 0 { + return "" + } + return unsafe.String(&b[0], len(b)) } // Bytes converts string to byte slice. func Bytes(s string) []byte { - return *(*[]byte)(unsafe.Pointer( - &struct { - string - Cap int - }{s, len(s)}, - )) + if s == "" { + return []byte{} + } + return unsafe.Slice(unsafe.StringData(s), len(s)) } |