mirror of https://github.com/gofiber/fiber.git
✏ fix typo
parent
d6f717148a
commit
d9ca77a834
|
@ -33,30 +33,13 @@ func SafeString(s string) string {
|
||||||
return string(UnsafeBytes(s))
|
return string(UnsafeBytes(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SafeBytes copies a slive to make it immutable
|
// SafeBytes copies a slice to make it immutable
|
||||||
func SafeBytes(b []byte) []byte {
|
func SafeBytes(b []byte) []byte {
|
||||||
tmp := make([]byte, len(b))
|
tmp := make([]byte, len(b))
|
||||||
copy(tmp, b)
|
copy(tmp, b)
|
||||||
return tmp
|
return tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
// #nosec G103
|
|
||||||
// GetString returns a string pointer without allocation
|
|
||||||
func GetString(b []byte) string {
|
|
||||||
return UnsafeString(b)
|
|
||||||
}
|
|
||||||
|
|
||||||
// #nosec G103
|
|
||||||
// GetBytes returns a byte pointer without allocation
|
|
||||||
func GetBytes(s string) []byte {
|
|
||||||
return UnsafeBytes(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImmutableString copies a string to make it immutable
|
|
||||||
func ImmutableString(s string) string {
|
|
||||||
return SafeString(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
uByte = 1 << (10 * iota)
|
uByte = 1 << (10 * iota)
|
||||||
uKilobyte
|
uKilobyte
|
||||||
|
@ -100,3 +83,22 @@ func ByteSize(bytes uint64) string {
|
||||||
result = strings.TrimSuffix(result, ".0")
|
result = strings.TrimSuffix(result, ".0")
|
||||||
return result + unit
|
return result + unit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated fn's
|
||||||
|
|
||||||
|
// #nosec G103
|
||||||
|
// GetString returns a string pointer without allocation
|
||||||
|
func GetString(b []byte) string {
|
||||||
|
return UnsafeString(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// #nosec G103
|
||||||
|
// GetBytes returns a byte pointer without allocation
|
||||||
|
func GetBytes(s string) []byte {
|
||||||
|
return UnsafeBytes(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImmutableString copies a string to make it immutable
|
||||||
|
func ImmutableString(s string) string {
|
||||||
|
return SafeString(s)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue