MCPcopy Create free account
hub / github.com/buger/jsonparser / StringToBytes

Function StringToBytes

bytes_unsafe.go:36–45  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

34}
35
36func StringToBytes(s string) []byte {
37 b := make([]byte, 0, 0)
38 bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
39 sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
40 bh.Data = sh.Data
41 bh.Cap = sh.Len
42 bh.Len = sh.Len
43 runtime.KeepAlive(s)
44 return b
45}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected