Documentation
¶
Index ¶
- func Bool(value string) (bool, error)
- func BoolP(value string) (*bool, error)
- func BoolSlice(val, sep string) ([]bool, error)
- func BracketsIntervals(s string, tokenBegin, tokenEnd rune) (string, bool)
- func Bytes(val string) ([]byte, error)
- func BytesSlice(val, sep string) ([][]byte, error)
- func CamelCase(s string) string
- func CamelCaseSlice(elem []string) string
- func CamelToSnake(name string) string
- func CommonRuneHandler(s string, rm func(r rune) bool) string
- func CommonRuneReplace(s string, f func(r rune) rune) string
- func Cut(s, sep string) (string, string, bool)
- func CutPart(s, sep string) string
- func CutPartContain(s, sep string) string
- func DJB33(seed uint32, k string) uint32
- func Float[T constraints.Float](value string) (T, error)
- func Float32(val string) (float32, error)
- func Float32P(val string) (*float32, error)
- func Float32Slice(val, sep string) ([]float32, error)
- func Float64(val string) (float64, error)
- func Float64P(val string) (*float64, error)
- func Float64Slice(val, sep string) ([]float64, error)
- func FloatP[T constraints.Float](value string) (*T, error)
- func FloatSlice[T constraints.Float](val, sep string) ([]T, error)
- func Format(t any) string
- func FormatInteger(value any) string
- func FormatLen(s string, length int) string
- func FormatReflectValue(value reflect.Value) string
- func FormatSigned[T constraints.Signed](v T) string
- func FormatUnsigned[T constraints.Unsigned](v T) string
- func FromBytes(b []byte) string
- func HasPrefixes(s string, prefixes []string) bool
- func Int(val string) (int, error)
- func Int8(val string) (int8, error)
- func Int8P(val string) (*int8, error)
- func Int8Slice(val, sep string) ([]int8, error)
- func Int16(val string) (int16, error)
- func Int16P(val string) (*int16, error)
- func Int16Slice(val, sep string) ([]int16, error)
- func Int32(val string) (int32, error)
- func Int32P(val string) (*int32, error)
- func Int32Slice(val, sep string) ([]int32, error)
- func Int64(val string) (int64, error)
- func Int64P(val string) (*int64, error)
- func Int64Slice(val, sep string) ([]int64, error)
- func IntP(val string) (*int, error)
- func IntSlice(val, sep string) ([]int, error)
- func IsEmpty(str string) bool
- func IsNumber(str string) bool
- func IsQuoted[T ~string | ~[]byte](s T) bool
- func Join[S ~[]T, T fmt.Stringer](s S, sep string) string
- func JoinFunc[S ~[]T, T any](s S, toString func(idx int, v T) string, sep string) string
- func JoinIndexFunc[S ~[]T, T any](s S, toString func(i int) string, sep string) string
- func JoinValueFunc[S ~[]T, T any](s S, toString func(v T) string, sep string) string
- func LowerCase(c byte) byte
- func LowerCaseFirst(t string) string
- func ParseFor[T any](str string) (T, error)
- func ParsePtrFor[T any](str string) (*T, error)
- func Rand(length int) string
- func RemoveEmoji(s string) string
- func RemoveRunes(s string, old ...rune) string
- func RemoveSymbol(s string) string
- func ReplaceBytes(s string, olds []byte, new byte) string
- func ReplaceBytesEmpty(s string, old ...byte) string
- func ReplaceRunes(s string, olds []rune, new rune) string
- func RetainHanAndASCII(s string) string
- func RetainHanAndASCIIGt32(s string) string
- func ReverseCut(s, sep string) (string, string, bool)
- func ReverseCutPart(s, key string) string
- func Signed[T constraints.Signed](value string) (T, error)
- func SignedP[T constraints.Signed](value string) (*T, error)
- func SignedSlice[T constraints.Signed](val, sep string) ([]T, error)
- func SnakeToCamel[T ~string](s T) string
- func SplitCamelCase(src string) (entries []string)
- func String(val string) (string, error)
- func StringSlice(val, sep string) ([]string, error)
- func ToBytes(s string) []byte
- func Uint(val string) (uint, error)
- func Uint8(val string) (uint8, error)
- func Uint8P(val string) (*uint8, error)
- func Uint8Slice(val, sep string) ([]uint8, error)
- func Uint16(val string) (uint16, error)
- func Uint16P(val string) (*uint16, error)
- func Uint16Slice(val, sep string) ([]uint16, error)
- func Uint32(val string) (uint32, error)
- func Uint32P(val string) (*uint32, error)
- func Uint32Slice(val, sep string) ([]uint32, error)
- func Uint64(val string) (uint64, error)
- func Uint64P(val string) (*uint64, error)
- func Uint64Slice(val, sep string) ([]uint64, error)
- func UintP(val string) (*uint, error)
- func UintSlice(val, sep string) ([]uint, error)
- func UnSigned[T constraints.Unsigned](value string) (T, error)
- func UnSignedP[T constraints.Unsigned](value string) (*T, error)
- func UnsignedSlice[T constraints.Unsigned](val, sep string) ([]T, error)
- func UpperCase(c byte) byte
- func UpperCaseFirst(t string) string
- type NumLetterSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolSlice ¶ added in v1.11.0
BoolSlice converts 'val' where individual booleans are separated by 'sep' into a bool slice.
func BracketsIntervals ¶
寻找括号区间 BracketsIntervals 在给定字符串中寻找由特定开始和结束符号包围的区间。 它会返回第一个找到的由tokenBegin和tokenEnd界定的字符串区间, 如果找到了则返回该区间和true,否则返回空字符串和false。
参数: s - 待搜索的字符串。 tokenBegin - 搜索的开始符号。 tokenEnd - 搜索的结束符号。
返回值: 第一个找到的由tokenBegin和tokenEnd界定的字符串区间, 如果找到了则返回该区间和true,否则返回空字符串和false。
func Bytes ¶ added in v1.11.0
Bytes converts the given string representation of a byte sequence into a slice of bytes A bytes sequence is encoded in URL-safe base64 without padding
func BytesSlice ¶ added in v1.11.0
BytesSlice converts 'val' where individual bytes sequences, encoded in URL-safe
base64 without padding, are separated by 'sep' into a slice of bytes slices slice.
func CamelCase ¶
CamelCase camel-cases a protobuf name for use as a Go identifier.
If there is an interior underscore followed by a lower case letter, drop the underscore and convert the letter to upper case.
func CamelCaseSlice ¶
func CamelToSnake ¶
func Float32 ¶ added in v1.11.0
Float32 converts the given string representation of a floating point number into float32.
func Float32Slice ¶ added in v1.11.0
Float32Slice converts 'val' where individual floating point numbers are separated by 'sep' into a float32 slice.
func Float64 ¶ added in v1.11.0
Float64 converts the given string representation into representation of a floating point number into float64.
func Float64Slice ¶ added in v1.11.0
Float64Slice converts 'val' where individual floating point numbers are separated by 'sep' into a float64 slice.
func FloatSlice ¶ added in v1.11.0
func FloatSlice[T constraints.Float](val, sep string) ([]T, error)
FloatSlice converts 'val' where individual floating point numbers are separated by 'sep' into a float slice.
func FormatInteger ¶ added in v1.11.0
func FormatReflectValue ¶ added in v1.11.0
func FormatSigned ¶ added in v1.11.0
func FormatSigned[T constraints.Signed](v T) string
func FormatUnsigned ¶ added in v1.11.0
func FormatUnsigned[T constraints.Unsigned](v T) string
func Int8Slice ¶ added in v1.11.0
Int8Slice converts 'val' where individual integers are separated by 'sep' into a int8 slice.
func Int16Slice ¶ added in v1.11.0
Int16Slice converts 'val' where individual integers are separated by 'sep' into a int slice.
func Int32 ¶ added in v1.11.0
Int32 converts the given string representation of an integer into int32.
func Int32Slice ¶ added in v1.11.0
Int32Slice converts 'val' where individual integers are separated by 'sep' into a int32 slice.
func Int64 ¶ added in v1.11.0
Int64 converts the given string representation of an integer into int64.
func Int64Slice ¶ added in v1.11.0
Int64Slice converts 'val' where individual integers are separated by 'sep' into a int64 slice.
func IntSlice ¶ added in v1.11.0
IntSlice converts 'val' where individual integers are separated by 'sep' into a int slice.
func JoinIndexFunc ¶ added in v1.7.0
func JoinValueFunc ¶ added in v1.7.0
func ParsePtrFor ¶ added in v1.11.0
func RemoveEmoji ¶
func RemoveRunes ¶
func RemoveSymbol ¶
func RetainHanAndASCII ¶
func RetainHanAndASCIIGt32 ¶
func SignedSlice ¶ added in v1.11.0
func SignedSlice[T constraints.Signed](val, sep string) ([]T, error)
SignedSlice converts 'val' where individual integers are separated by 'sep' into a Signed slice.
func SnakeToCamel ¶
func SplitCamelCase ¶
Split splits the camelcase word and returns a list of words. It also supports digits. Both lower camel case and upper camel case are supported. For more info please check: http://en.wikipedia.org/wiki/CamelCase
Examples
"" => [""] "lowercase" => ["lowercase"] "Class" => ["Class"] "MyClass" => ["My", "Class"] "MyC" => ["My", "C"] "HTML" => ["HTML"] "PDFLoader" => ["PDF", "Loader"] "AString" => ["A", "Chinese"] "SimpleXMLParser" => ["Simple", "XML", "Parser"] "vimRPCPlugin" => ["vim", "RPC", "Plugin"] "GL11Version" => ["GL", "11", "Version"] "99Bottles" => ["99", "Bottles"] "May5" => ["May", "5"] "BFG9000" => ["BFG", "9000"] "BöseÜberraschung" => ["Böse", "Überraschung"] "Two spaces" => ["Two", " ", "spaces"] "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"]
Splitting rules
- If string is not valid UTF-8, return it without splitting as single item array.
- Assign all unicode characters into one of 4 sets: lower case letters, upper case letters, numbers, and all other characters.
- Iterate through characters of string, introducing splits between adjacent characters that belong to different sets.
- Iterate through array of split strings, and if a given string is upper case: if subsequent string is lower case: move last character of upper case string to beginning of lower case string
func StringSlice ¶ added in v1.11.0
StringSlice converts 'val' where individual strings are separated by 'sep' into a string slice.
func Uint8Slice ¶ added in v1.11.0
Uint8Slice converts 'val' where individual integers are separated by 'sep' into a uint8 slice.
func Uint16Slice ¶ added in v1.11.0
Uint16Slice converts 'val' where individual integers are separated by 'sep' into a uint slice.
func Uint32 ¶ added in v1.11.0
Uint32 converts the given string representation of an integer into uint32.
func Uint32Slice ¶ added in v1.11.0
Uint32Slice converts 'val' where individual integers are separated by 'sep' into a uint32 slice.
func Uint64 ¶ added in v1.11.0
Uint64 converts the given string representation of an integer into uint64.
func Uint64Slice ¶ added in v1.11.0
Uint64Slice converts 'val' where individual integers are separated by 'sep' into a uint64 slice.
func UintSlice ¶ added in v1.11.0
UintSlice converts 'val' where individual integers are separated by 'sep' into a uint slice.
func UnsignedSlice ¶ added in v1.11.0
func UnsignedSlice[T constraints.Unsigned](val, sep string) ([]T, error)
UnsignedSlice converts 'val' where individual integers are separated by 'sep' into a Unsigned slice.
func UpperCaseFirst ¶
Types ¶
type NumLetterSlice ¶
type NumLetterSlice[T any] ['z' - '0' + 1]T