We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6ff375d + 6504538 commit dc2b0caCopy full SHA for dc2b0ca
utils.go
@@ -255,8 +255,11 @@ func strCmp(s1, s2 string) int {
255
}
256
257
258
-func unsafeFastStringToReadOnlyBytes(s string) []byte {
+func unsafeFastStringToReadOnlyBytes(s string) (bs []byte) {
259
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
260
- bh := reflect.SliceHeader{Data: sh.Data, Len: sh.Len, Cap: sh.Len}
261
- return *(*[]byte)(unsafe.Pointer(&bh))
+ bh := (*reflect.SliceHeader)(unsafe.Pointer(&bs))
+ bh.Data = sh.Data
262
+ bh.Cap = sh.Len
263
+ bh.Len = sh.Len
264
+ return
265
0 commit comments