b2s.go 273 B

123456789
  1. package fasthttpadaptor
  2. import "unsafe"
  3. // b2s converts byte slice to a string without memory allocation.
  4. // See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .
  5. func b2s(b []byte) string {
  6. return unsafe.String(unsafe.SliceData(b), len(b))
  7. }