s2b_new.go 211 B

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