summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/extra/bunotel/unsafe.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/uptrace/bun/extra/bunotel/unsafe.go')
-rw-r--r--vendor/github.com/uptrace/bun/extra/bunotel/unsafe.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/vendor/github.com/uptrace/bun/extra/bunotel/unsafe.go b/vendor/github.com/uptrace/bun/extra/bunotel/unsafe.go
index 23accd40e..67b687cbe 100644
--- a/vendor/github.com/uptrace/bun/extra/bunotel/unsafe.go
+++ b/vendor/github.com/uptrace/bun/extra/bunotel/unsafe.go
@@ -1,3 +1,4 @@
+//go:build !appengine
// +build !appengine
package bunotel
@@ -5,14 +6,15 @@ package bunotel
import "unsafe"
func bytesToString(b []byte) string {
- return *(*string)(unsafe.Pointer(&b))
+ if len(b) == 0 {
+ return ""
+ }
+ return unsafe.String(&b[0], len(b))
}
func stringToBytes(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))
}