Documentation
¶
Overview ¶
Package byteconv implements conversions to and from byte representations of basic data types. It aims to be a zero-allocation, highly performant 1-to-1 equivalent of the standard library's strconv package, but operates directly on byte slices ([]byte) to avoid string conversions and memory allocations.
Index ¶
- Constants
- func Atoi(s []byte) (int, error)
- func ParseBool(in []byte) (bool, error)
- func ParseComplex(s []byte, bitSize int) (complex128, error)
- func ParseFloat(s []byte, bitSize int) (float64, error)
- func ParseInt(s []byte, base int, bitSize int) (i int64, err error)
- func ParseUint(s []byte, base int, bitSize int) (uint64, error)
- type Error
Constants ¶
const IntSize = intSize
IntSize is the size in bits of an int or uint value.
Variables ¶
This section is empty.
Functions ¶
func ParseBool ¶
ParseBool returns the boolean value represented by the []byte. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error.
func ParseComplex ¶
func ParseComplex(s []byte, bitSize int) (complex128, error)
ParseComplex converts the []byte s to a complex number with the precision specified by bitSize: 64 for complex64, or 128 for complex128. When bitSize=64, the result still has type complex128, but it will be convertible to complex64 without changing its value.
Types ¶
type Error ¶
type Error int
Error represents an error during a conversion.
const ( // ErrRange indicates that a value is out of range for the target type. ErrRange Error // ErrSyntax indicates that a value does not have the right syntax for the target type. ErrSyntax // ErrBase indicates that a base is invalid. ErrBase // ErrBitSize indicates that a bit size is invalid. ErrBitSize )
Ran on AMD Ryzen 9 9950X3D 16-Core Processor