Documentation
¶
Index ¶
- Variables
- func AnySet(dst any, val string, valueAppend bool)
- func Bool[T ~bool](s string, def ...T) (r T)
- func Bytes(s string) []byte
- func Compaare(a, b string) int
- func Cut(s, sep string) (prefix, suffix string, ok bool)
- func Duration(t time.Duration) string
- func Equal(a, b string) bool
- func Fields(s string) []string
- func FieldsFunc(s string, f func(rune) bool) []string
- func Float[T ~float32 | ~float64](s string, def ...T) (r T)
- func FromBytes(b []byte) string
- func FromInt[T Ints](i T, base int) string
- func FromUint[T Uints](i T, base int) string
- func HasPrefix(s string, prefix string) bool
- func HasSuffix(s string, suffix string) bool
- func Index(s string, substr string) int
- func IndexFunc(s string, f func(rune) bool) int
- func Int[T Ints](s string, def ...T) (r T)
- func Join(strs []string, sep string) string
- func Lower(s string) string
- func ParseDuration(s string) (t time.Duration, err error)
- func ParseIP(val string) (net.IP, error)
- func Percent(cur, total int64) string
- func Prefix(s string, sep string) string
- func Prefix2(s1, s2 string, sep string) (string, string)
- func PrefixMatch(prefix ...string) func(string) bool
- func Replace(s, old, new string, n ...int) string
- func Size(bytes int64) string
- func Split(s, sep string) []string
- func Suffix(s string, sep string) string
- func Suffix2(s1, s2 string, sep string) (string, string)
- func SuffixMatch(suffix string) func(string) bool
- func TrimExe(s string) string
- func TrimFunc(s string, f func(rune) bool) string
- func TrimPrefix(s, prefix string) string
- func TrimSpace(s string) string
- func TrimSuffix(s, suffix string) string
- func Uint[T Uints](s string, def ...T) (r T)
- func Upper(s string) string
- type Floats
- type Ints
- type Setter
- type Strs
- type Uints
Constants ¶
This section is empty.
Variables ¶
var Windows = runtime.GOOS == "windows"
Functions ¶
func Compaare ¶
Compare returns an integer comparing two strings lexicographically. The result will be 0 if a == b, -1 if a < b, and +1 if a > b.
Use Compare when you need to perform a three-way comparison (with slices.SortFunc, for example). It is usually clearer and always faster to use the built-in string comparison operators ==, <, >, and so on.
func Cut ¶
Cut slices s around the first instance of sep, returning the text before and after sep. The found result reports whether sep appears in s. If sep does not appear in s, cut returns s, "", false.
func Fields ¶
Fields 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.
func FieldsFunc ¶
FieldsFunc 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.
FieldsFunc makes no guarantees about the order in which it calls f(c) and assumes that f always returns the same value for a given c.
func HasPrefix ¶
HasPrefix reports whether the string s begins with prefix. case-insensitive on Windows.
func HasSuffix ¶
HasSuffix reports whether the string s ends with suffix. case-insensitive on Windows.
func Index ¶
Index returns the index of the first instance of substr in s, or -1 if substr is not present in s.
func IndexFunc ¶
IndexFunc returns the index into s of the first Unicode code point satisfying f(c), or -1 if none do.
func Join ¶
Join concatenates the elements of its first argument to create a single string. The separator string sep is placed between elements in the resulting string.
func Prefix ¶
Prefix returns the left part of the string before the first occurrence of the separator.
func Prefix2 ¶
Prefix2 returns the left part of the string before the first occurrence of the separator.
func PrefixMatch ¶
PrefixMatch returns a function that returns true if the given string starts with any of the given prefixes.
func Replace ¶
Replace returns a copy of the string s with the first n non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the string and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune string. If n < 0, or len(n) == 0 there is no limit on the number of replacements.
func Suffix ¶
Suffix returns the right part of the string after the first occurrence of the separator.
func Suffix2 ¶
Suffix2 returns the right part of the string after the first occurrence of the separator.
func SuffixMatch ¶
SuffixMatch returns a function that returns true if the given string ends with the given suffix.
func TrimFunc ¶
TrimFunc returns a slice of the string s with all leading and trailing Unicode code points c satisfying f(c) removed.
func TrimPrefix ¶
TrimPrefix returns s without the provided leading prefix string. case-insensitive on Windows.
func TrimSpace ¶
TrimSpace returns a slice of the string s, with all leading and trailing white space removed, as defined by Unicode.
func TrimSuffix ¶
TrimSuffix returns s without the provided trailing suffix string. case-insensitive on Windows.