mirror of
https://github.com/gofiber/fiber.git
synced 2025-05-28 18:32:39 +00:00
* utils: add Go 1.20+ way of converting string to byte slice Ref.d2f97fc426/s2b_old.go
. Ref.d2f97fc426/s2b_new.go
. * utils: fix golangci-lint apparently running with Go < 1.20 See https://github.com/gofiber/fiber/actions/runs/4968641325/jobs/8891360463?pr=2462.
14 lines
220 B
Go
14 lines
220 B
Go
//go:build go1.20
|
|
// +build go1.20
|
|
|
|
package utils
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
// UnsafeBytes returns a byte pointer without allocation.
|
|
func UnsafeBytes(s string) []byte {
|
|
return unsafe.Slice(unsafe.StringData(s), len(s))
|
|
}
|