Documentation ¶
Index ¶
- Constants
- func BoolTo[T Integer](b bool) T
- func BytesAsStr(b []byte) string
- func IntToBool[T Integer](v T) bool
- func MustParseF32(s string) float32
- func MustParseF64(s string) float64
- func MustParseI16(s string) int16
- func MustParseI32(s string) int32
- func MustParseI64(s string) int64
- func MustParseI8(s string) int8
- func MustParseTo[T cmp.Ordered | bool](s string) T
- func MustParseU16(s string) uint16
- func MustParseU32(s string) uint32
- func MustParseU64(s string) uint64
- func MustParseU8(s string) uint8
- func ParseBool(s string) bool
- func ParseF32(s string) (float32, error)
- func ParseF64(s string) (float64, error)
- func ParseI16(s string) (int16, error)
- func ParseI32(s string) (int32, error)
- func ParseI64(s string) (int64, error)
- func ParseI8(s string) (int8, error)
- func ParseKeyValues[K, V cmp.Ordered](text string, sep1, sep2 string) ([]K, []V)
- func ParseMap[K, V cmp.Ordered](text string, sep1, sep2 string) map[K]V
- func ParseSlice[T cmp.Ordered](text, sep string) []T
- func ParseTo[T cmp.Ordered | bool](s string) (T, error)
- func ParseU16(s string) (uint16, error)
- func ParseU32(s string) (uint32, error)
- func ParseU64(s string) (uint64, error)
- func ParseU8(s string) (uint8, error)
- func StrAsBytes(s string) []byte
- type Integer
Constants ¶
const ( SepSpace = " " SepColon = ":" SepComma = "," SepEqualSign = "=" SepVerticalBar = "|" )
Variables ¶
This section is empty.
Functions ¶
func MustParseF32 ¶
MustParseF32 parse string to float32, panic if error
func MustParseF64 ¶
MustParseF64 parse string to float64, panic if error
func MustParseI16 ¶
MustParseI16 parse string to int16, panic if error
func MustParseI32 ¶
MustParseI32 parse string to int32, panic if error
func MustParseI64 ¶
MustParseI64 parse string to int64, panic if error
func MustParseU16 ¶
MustParseU16 parse string to uint16, panic if error
func MustParseU32 ¶
MustParseU32 parse string to uint32, panic if error
func MustParseU64 ¶
MustParseU64 parse string to uint64, panic if error
func MustParseU8 ¶
MustParseU8 parse string to uint8, panic if error
func ParseKeyValues ¶
ParseKeyValues 解析字符串为K-V slice
func ParseMap ¶
ParseMap 解析字符串为K-V map, 示例: ParseKVPairs("x=1|y=2", SepEqualSign, SepVerticalBar) -> {"a":"x,y", "c":"z"}
func ParseSlice ¶
func ParseTo ¶
ParseTo parse string to any number type this generic routine is 12%-20% slower than concrete ParseXXX version, see conv_test.go
func StrAsBytes ¶
StrAsBytes returns the bytes backing a string, it is the caller's responsibility not to mutate the bytes returned. see https://pkg.go.dev/unsafe#Pointer rule(6)