Documentation ¶
Overview ¶
The clike package provides some functions that behave more like the traditional Clib functions than functions supported by the Go packages. Currently these all revolve around the atoX() family of Clib functions which do not error when they encounter a non-digit, and return a 0 if the leading character in the string is not numeric or a sign. These Clike functions all stop parsing when the first non digit is encountered.
A small extension has been added which allows the string representation to contain a trailing suffix. The suffix causes the function to expand the value. For example the suffix M causes the value to be expanded to 1000000 times the string value. The following suffixes are supported:
MiB or m power of 2 GiB or g power of 2 KiB or k power of 2 M power of 10 G power of 10 K power of 10
The integer based functions all accept a leading '0x' or '0' to indicate that the string should be interpreted as a hex or octal value respectively.
The functions all accept either a string or an array of bytes ([]byte).
Index ¶
- func Atof(objx interface{}) (v float64)
- func Atoi(objx interface{}) int
- func Atoi16(objx interface{}) int16
- func Atoi32(objx interface{}) int32
- func Atoi64(objx interface{}) int64
- func Atoll(objx interface{}) (v int64)
- func Atou(objx interface{}) uint
- func Atou16(objx interface{}) uint16
- func Atou32(objx interface{}) uint32
- func Atou64(objx interface{}) uint64
- func Atoull(objx interface{}) (v uint64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Atof ¶
func Atof(objx interface{}) (v float64)
Atof accepts a string or an array of bytes ([]byte) and converts the characters into a float64 value. The input may be postfixed with either any of the following characters which cause the value to be expanded:
m,k,g - powers of two expansion. e.g. 10m expands to 10 * 1024 * 1024. M,K,G - powers of ten expansion. e.g. 10M expands to 10000000
Unlike the Go string functions, this stops parsing at the first non-digit in the same manner that the Clib functions do.
func Atoi ¶
func Atoi(objx interface{}) int
Convert a string or an array of bytes into a default sized integer.
func Atoi16 ¶
func Atoi16(objx interface{}) int16
Convert a string or an array of bytes into a 16 bit integer.
func Atoi32 ¶
func Atoi32(objx interface{}) int32
Convert a string or an array of bytes into a 32 bit integer.
func Atoi64 ¶
func Atoi64(objx interface{}) int64
Convert a string or an array of bytes into a 64 bit integer.
func Atoll ¶
func Atoll(objx interface{}) (v int64)
Convert a string or an array of bytes into a 64 bit integer.
func Atou ¶
func Atou(objx interface{}) uint
Convert a string or an array of bytes into an unsigned integer.
func Atou16 ¶
func Atou16(objx interface{}) uint16
Convert a string or an array of bytes into a 16 bit integer.
func Atou32 ¶
func Atou32(objx interface{}) uint32
Convert a string or an array of bytes into a 32 bit integer.
Types ¶
This section is empty.