Documentation ¶
Overview ¶
Package strconvh provides functions for conversion between basic types and its string representations.
String representation for numeric use 10-base. Most of functions have suffix in form of [u]int[8,16,32,64] or float{32,64}. This suffix defines inputs and outputs types for number parameters. So it helps avoid a lot of conversions in code.
Index ¶
- func FormatBool(b bool) string
- func FormatComplex128(c complex128) string
- func FormatComplex128Prec(c complex128, prec int) string
- func FormatComplex64(c complex64) string
- func FormatComplex64Prec(c complex64, prec int) string
- func FormatFloat32(f float32) string
- func FormatFloat32Prec(f float32, prec int) string
- func FormatFloat64(f float64) string
- func FormatFloat64Prec(f float64, prec int) string
- func FormatInt(i int) string
- func FormatInt16(i int16) string
- func FormatInt32(i int32) string
- func FormatInt64(i int64) string
- func FormatInt8(i int8) string
- func FormatUint(i uint) string
- func FormatUint16(i uint16) string
- func FormatUint32(i uint32) string
- func FormatUint64(i uint64) string
- func FormatUint8(i uint8) string
- func ParseBool(str string) (bool, error)
- func ParseComplex128(s string) (c complex128, err error)
- func ParseComplex64(s string) (c complex64, err error)
- func ParseFloat32(s string) (f float32, err error)
- func ParseFloat64(s string) (float64, error)
- func ParseInt(stringValue string) (i int, err error)
- func ParseInt16(stringValue string) (i int16, err error)
- func ParseInt32(stringValue string) (i int32, err error)
- func ParseInt64(stringValue string) (int64, error)
- func ParseInt8(stringValue string) (i int8, err error)
- func ParseUint(stringValue string) (i uint, err error)
- func ParseUint16(stringValue string) (i uint16, err error)
- func ParseUint32(stringValue string) (i uint32, err error)
- func ParseUint64(stringValue string) (uint64, error)
- func ParseUint8(stringValue string) (i uint8, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatBool ¶
FormatBool returns "true" or "false" according to the value of b
func FormatComplex128 ¶
func FormatComplex128(c complex128) string
FormatComplex128 is a shortcut for FormatComplex128Prec with prec=-1.
func FormatComplex128Prec ¶
func FormatComplex128Prec(c complex128, prec int) string
FormatComplex128Prec returns the string representation of c in form of "(-1.2+3.4i)". The precision prec controls the number of digits after the decimal point. The special precision -1 uses the smallest number of digits necessary such that ParseComplex128Prec will return c exactly.
func FormatComplex64 ¶
FormatComplex64 is a shortcut for FormatComplex64Prec with prec=-1.
func FormatComplex64Prec ¶
FormatComplex64Prec returns the string representation of c in form of "(-1.2+3.4i)". The precision prec controls the number of digits after the decimal point. The special precision -1 uses the smallest number of digits necessary such that ParseComplex64Prec will return c exactly.
func FormatFloat32 ¶
FormatFloat32 is a shortcut for FormatFloat32Prec with prec=-1.
func FormatFloat32Prec ¶
FormatFloat32Prec returns the string representation of f in the 10-base. The precision prec controls the number of digits after the decimal point. The special precision -1 uses the smallest number of digits necessary such that ParseFloat32Prec will return f exactly.
func FormatFloat64 ¶
FormatFloat64 is a shortcut for FormatFloat64Prec with prec=-1.
func FormatFloat64Prec ¶
FormatFloat64Prec returns the string representation of f in the 10-base. The precision prec controls the number of digits after the decimal point. The special precision -1 uses the smallest number of digits necessary such that ParseFloat64Prec will return f exactly.
func FormatInt16 ¶
FormatInt16 returns the string representation of i in the 10-base.
func FormatInt32 ¶
FormatInt32 returns the string representation of i in the 10-base.
func FormatInt64 ¶
FormatInt64 returns the string representation of i in the 10-base.
func FormatInt8 ¶
FormatInt8 returns the string representation of i in the 10-base.
func FormatUint ¶
FormatUint returns the string representation of i in the 10-base.
func FormatUint16 ¶
FormatUint16 returns the string representation of i in the 10-base.
func FormatUint32 ¶
FormatUint32 returns the string representation of i in the 10-base.
func FormatUint64 ¶
FormatUint64 returns the string representation of i in the 10-base.
func FormatUint8 ¶
FormatUint8 returns the string representation of i in the 10-base.
func ParseBool ¶
ParseBool returns the boolean value represented by the string. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error.
func ParseComplex128 ¶
func ParseComplex128(s string) (c complex128, err error)
ParseComplex128 converts the string s to a complex128. Valid form are "<float64>","<float64>i","<float64><float64 with sign>i" and optionally can be parenthesized. ParseComplex128 internally uses ParseFloat64 for parsing real and imaginary parts. The errors that ParseComplex128 returns have concrete type *NumError and include err.Num = s.
func ParseComplex64 ¶
ParseComplex64 converts the string s to a complex64. Valid form are "<float32>","<float32>i","<float32><float32 with sign>i" and optionally can be parenthesized. ParseComplex64 internally uses ParseFloat32 for parsing real and imaginary parts. The errors that ParseComplex64 returns have concrete type *NumError and include err.Num = s.
func ParseFloat32 ¶
ParseFloat32 interprets a string s in 10-base and returns the corresponding value f (float32) and error.
func ParseFloat64 ¶
ParseFloat64 interprets a string s in 10-base and returns the corresponding value f (float64) and error.
func ParseInt ¶
ParseInt interprets a string s in 10-base and returns the corresponding value i (int) and error.
func ParseInt16 ¶
ParseInt16 interprets a string s in 10-base and returns the corresponding value i (int16) and error.
func ParseInt32 ¶
ParseInt32 interprets a string s in 10-base and returns the corresponding value i (int32) and error.
func ParseInt64 ¶
ParseInt64 interprets a string s in 10-base and returns the corresponding value i (int64) and error.
func ParseInt8 ¶
ParseInt8 interprets a string s in 10-base and returns the corresponding value i (int8) and error.
func ParseUint ¶
ParseUint interprets a string s in 10-base and returns the corresponding value i (uint) and error.
func ParseUint16 ¶
ParseUint16 interprets a string s in 10-base and returns the corresponding value i (uint16) and error.
func ParseUint32 ¶
ParseUint32 interprets a string s in 10-base and returns the corresponding value i (uint32) and error.
func ParseUint64 ¶
ParseUint64 interprets a string s in 10-base and returns the corresponding value i (uint64) and error.
func ParseUint8 ¶
ParseUint8 interprets a string s in 10-base and returns the corresponding value i (uint8) and error.
Types ¶
This section is empty.