✏ fix typo

pull/833/head
Fenny 2020-09-27 12:23:46 +02:00
parent d6f717148a
commit d9ca77a834
1 changed files with 20 additions and 18 deletions

View File

@ -33,30 +33,13 @@ func SafeString(s string) string {
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 {
tmp := make([]byte, len(b))
copy(tmp, b)
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 (
uByte = 1 << (10 * iota)
uKilobyte
@ -100,3 +83,22 @@ func ByteSize(bytes uint64) string {
result = strings.TrimSuffix(result, ".0")
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)
}