MCPcopy
hub / github.com/gin-gonic/gin / StringToBytes

Function StringToBytes

internal/bytesconv/bytesconv.go:13–15  ·  view source on GitHub ↗

StringToBytes converts string to byte slice without a memory allocation. For more details, see https://github.com/golang/go/issues/53003#issuecomment-1140276077.

(s string)

Source from the content-addressed store, hash-verified

11// StringToBytes converts string to byte slice without a memory allocation.
12// For more details, see https://github.com/golang/go/issues/53003#issuecomment-1140276077.
13func StringToBytes(s string) []byte {
14 return unsafe.Slice(unsafe.StringData(s), len(s))
15}
16
17// BytesToString converts byte slice to string without a memory allocation.
18// For more details, see https://github.com/golang/go/issues/53003#issuecomment-1140276077.

Callers 9

searchCredentialMethod · 0.92
authorizationHeaderFunction · 0.92
WriteStringFunction · 0.92
RenderMethod · 0.92
RenderMethod · 0.92
setWithProperTypeFunction · 0.92
TestStringToBytesFunction · 0.85
TestStringToBytesEmptyFunction · 0.85

Calls

no outgoing calls

Tested by 3

TestStringToBytesFunction · 0.68
TestStringToBytesEmptyFunction · 0.68