unsafeConvert

package module
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 2 Imported by: 46

README

Unsafe string↔[]byte conversion library

The library functions for unsafely convert between a string and a slice of bytes. You probably shouldn’t use it unless you need to squeeze extra performance from your performance-critical code path.

See https://mina86.com/2017/golang-string-and-bytes/ for some more info.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteCopy added in v1.5.0

func ByteCopy(s string) []byte

func BytePointer added in v1.5.0

func BytePointer(v string) []byte

func ByteSlice added in v1.5.0

func ByteSlice(v string) []byte

func Int64ToString added in v1.1.0

func Int64ToString(v int64) string

func IntToString added in v1.1.0

func IntToString(v int) string

func STBPointer added in v1.5.0

func STBPointer[T ~string | ~[]byte](v T) string

Note that this method is extremely dangerous, please do not use this method unless absolutely necessary!

Before generics were used, this method could cause memory usage exceptions, leading to system unresponsiveness (no matter how much memory is installed). This problem has been fixed by adding generics, but there is no guarantee that memory exceptions will not continue to occur in the future.

----------------------------------------------------------------

This method is used to convert any type to a string type. However, please note that not all types can be converted.

Abusing this method can lead to program crashes or even system crashes. So before converting, please test in a virtual environment whether the type you want to convert can be converted, in order to avoid loss.

func StringPointer added in v1.5.0

func StringPointer(v []byte) string

func StringSlice added in v1.5.0

func StringSlice(v []byte) string

func StringToInt added in v1.1.0

func StringToInt(v string) int

func StringToInt64 added in v1.1.0

func StringToInt64(v string) int64

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL