s2b_new.go 218 B

1234567891011
  1. //go:build go1.20
  2. // +build go1.20
  3. package fasthttp
  4. import "unsafe"
  5. // s2b converts string to a byte slice without memory allocation.
  6. func s2b(s string) []byte {
  7. return unsafe.Slice(unsafe.StringData(s), len(s))
  8. }