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.
1 parent 9ef61d6 commit 3988ce1Copy full SHA for 3988ce1
util.go
@@ -11,11 +11,11 @@ func b2s(b []byte) string {
11
return *(*string)(unsafe.Pointer(&b))
12
}
13
14
-func s2b(s string) []byte {
+func s2b(s string) (b []byte) {
15
strh := (*reflect.StringHeader)(unsafe.Pointer(&s))
16
- var sh reflect.SliceHeader
+ sh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
17
sh.Data = strh.Data
18
sh.Len = strh.Len
19
sh.Cap = strh.Len
20
- return *(*[]byte)(unsafe.Pointer(&sh))
+ return b
21
0 commit comments