Documentation ¶
Index ¶
- func AnyOf(s string, ss ...string) bool
- func AnyOfFold(s string, ss ...string) bool
- func Contains(s string, ss ...string) bool
- func ContainsFold(s string, ss ...string) bool
- func ExpandRange(f string) []string
- func FieldsFuncN(s string, n int, f func(rune) bool) []string
- func FieldsFuncX(s, keepStart, keepEnd string, count int, f func(rune) bool) []string
- func FieldsN(s string, count int) []string
- func FieldsX(s, keepStart, keepEnd string, count int) []string
- func FirstWord(s string) string
- func FormatFloat(f float64) string
- func FormatFloatOption(f float64, fns ...FormatFloatOptionConfigFn) string
- func Has(str string, predicates ...func(rune) bool) bool
- func HasPrefix(s string, ss ...string) bool
- func HasSpaces(str string) bool
- func HasSuffix(s string, ss ...string) bool
- func If(b bool, s1, s2 string) string
- func Ifi(b bool, s1, s2 int) int
- func IsDigits(s string) bool
- func JoinMap(m map[string]string, kvSep, kkSep string) (s string)
- func Left(s string, n int) string
- func Not(p func(rune) bool) func(rune) bool
- func Or(a, b string) string
- func Ori(a, b int) int
- func ParseBool(s string) bool
- func ParseBoolE(s string) (bool, error)
- func ParseDuration(s string) time.Duration
- func ParseDurationE(s string) (time.Duration, error)
- func ParseFloat32(s string) float32
- func ParseFloat32E(s string) (float32, error)
- func ParseFloat64(s string) float64
- func ParseFloat64E(s string) (float64, error)
- func ParseInt(s string) int
- func ParseInt16(s string) int16
- func ParseInt16E(s string) (int16, error)
- func ParseInt32(s string) int32
- func ParseInt32E(s string) (int32, error)
- func ParseInt64(s string) int64
- func ParseInt64E(s string) (int64, error)
- func ParseInt8(s string) int8
- func ParseInt8E(s string) (int8, error)
- func ParseIntE(s string) (int, error)
- func ParseUint(s string) uint
- func ParseUint16(s string) uint16
- func ParseUint16E(s string) (uint16, error)
- func ParseUint32(s string) uint32
- func ParseUint32E(s string) (uint32, error)
- func ParseUint64(s string) uint64
- func ParseUint64E(s string) (uint64, error)
- func ParseUint8(s string) uint8
- func ParseUint8E(s string) (uint8, error)
- func ParseUintE(s string) (uint, error)
- func PickFirst(s string, _ interface{}) string
- func RemoveAll(s, old string) string
- func Repeat(s, sep string, n int) string
- func Split(s string, options ...SplitOption) []string
- func Split1(s string, options ...SplitOption) (s0 string)
- func Split2(s string, options ...SplitOption) (s0, s1 string)
- func Split3(s string, options ...SplitOption) (s0, s1, s2 string)
- func Split4(s string, options ...SplitOption) (s0, s1, s2, s3 string)
- func Split5(s string, options ...SplitOption) (s0, s1, s2, s3, s4 string)
- func SplitToMap(s string, kvSep, kkSep string) map[string]string
- func Strip(str string, predicates ...func(rune) bool) string
- func StripSpaces(str string) string
- func ToLowerKebab(name string) string
- func ToSet(v []string) map[string]bool
- type Case
- type FormatFloatOptionConfig
- type FormatFloatOptionConfigFn
- type SplitConfig
- type SplitOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsFold ¶
func ExpandRange ¶
ExpandRange expands a string like 1-3 to [1,2,3]
func FieldsFuncN ¶
FieldsFuncN splits the string s at each run of Unicode code points c satisfying f(c) and returns an array of slices of s. If all code points in s satisfy f(c) or the string is empty, an empty slice is returned. FieldsFuncN makes no guarantees about the order in which it calls f(c). If f does not return consistent results for a given c, FieldsFuncN may crash.
func FieldsFuncX ¶
FieldsFuncX splits the string s at each run of Unicode code points c satisfying f(c) and returns an array of slices of s. If all code points in s satisfy f(c) or the string is empty, an empty slice is returned. FieldsFuncN makes no guarantees about the order in which it calls f(c). If f does not return consistent results for a given c, FieldsFuncN may crash.
func FieldsN ¶
FieldsN splits the string s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning a slice of substrings of s or an empty slice if s contains only white space. The count determines the number of substrings to return:
n > 0: at most n substrings; the last substring will be the unsplit remainder. n == 0: the result is nil (zero substrings) n < 0: all substrings
Code are copy from strings.Fields and add count parameter to control the max fields.
func FieldsX ¶
FieldsX splits the string s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning a slice of substrings of s or an empty slice if s contains only white space. The count determines the number of substrings to return:
n > 0: at most n substrings; the last substring will be the unsplit remainder. n == 0: the result is nil (zero substrings) n < 0: all substrings
Code are copy from strings.Fields and add count parameter to control the max fields.
func FormatFloat ¶
FormatFloat format a float64 to a string with the fewest digits necessary.
func FormatFloatOption ¶
func FormatFloatOption(f float64, fns ...FormatFloatOptionConfigFn) string
func ParseBool ¶
ParseBool returns the boolean value represented by the string. It accepts 1, t, true, y, yes, on with camel case incentive.
func ParseBoolE ¶
ParseBoolE returns the boolean value represented by the string. It accepts 1, t, true, y, yes, on as true with camel case incentive and accepts 0, f false, n, no, off as false with camel case incentive Any other value returns an error.
func Split ¶
func Split(s string, options ...SplitOption) []string
func Split2 ¶
func Split2(s string, options ...SplitOption) (s0, s1 string)
Split2 将s按分隔符sep分成x份,取第1、2份
func Split3 ¶
func Split3(s string, options ...SplitOption) (s0, s1, s2 string)
Split3 将s按分隔符sep分成x份,取第1、2、3份
func Split4 ¶
func Split4(s string, options ...SplitOption) (s0, s1, s2, s3 string)
Split4 将s按分隔符sep分成x份,取第x份,取第1、2、3、4份
func Split5 ¶
func Split5(s string, options ...SplitOption) (s0, s1, s2, s3, s4 string)
Split5 将s按分隔符sep分成x份,取第x份,取第1、2、3、4、5份
func SplitToMap ¶
SplitToMap 将字符串s分割成map,其中key和value之间的间隔符是kvSep, kv和kv之间的分隔符是kkSep
func StripSpaces ¶
StripSpaces strips all spaces from the string.
func ToLowerKebab ¶
Types ¶
type FormatFloatOptionConfig ¶
type FormatFloatOptionConfig struct { // Prec controls the number of digits (excluding the exponent) // printed by the 'e', 'E', 'f', 'g', 'G', 'x', and 'X' formats. // For 'e', 'E', 'f', 'x', and 'X', it is the number of digits after the decimal point. // For 'g' and 'G' it is the maximum number of significant digits (trailing zeros are removed). // The special precision -1 uses the smallest number of digits Prec int RemoveTrailingZeros bool }
type FormatFloatOptionConfigFn ¶
type FormatFloatOptionConfigFn func(*FormatFloatOptionConfig)
func WithPrec ¶
func WithPrec(prec int) FormatFloatOptionConfigFn
func WithRemoveTrailingZeros ¶
func WithRemoveTrailingZeros(yes bool) FormatFloatOptionConfigFn
type SplitConfig ¶
type SplitOption ¶
type SplitOption func(*SplitConfig)
func WithCase ¶
func WithCase(v Case) SplitOption
func WithConfig ¶
func WithConfig(v SplitConfig) SplitOption
func WithIgnoreEmpty ¶
func WithIgnoreEmpty(v bool) SplitOption
func WithN ¶
func WithN(v int) SplitOption
func WithSeps ¶
func WithSeps(v string) SplitOption
func WithTrimSpace ¶
func WithTrimSpace(v bool) SplitOption