convert_s2b_new.go 220 B

12345678910111213
  1. //go:build go1.20
  2. // +build go1.20
  3. package utils
  4. import (
  5. "unsafe"
  6. )
  7. // UnsafeBytes returns a byte pointer without allocation.
  8. func UnsafeBytes(s string) []byte {
  9. return unsafe.Slice(unsafe.StringData(s), len(s))
  10. }