Documentation ¶
Overview ¶
Package str provides string manipulation utilities.
Index ¶
- func Contains(x []string, s string) bool
- func FoldDup(list []string) (string, string)
- func HasFilePathPrefix(s, prefix string) bool
- func HasPathPrefix(s, prefix string) bool
- func QuoteGlob(s string) string
- func StringList(args ...any) []string
- func ToFold(s string) string
- func TrimFilePathPrefix(s, prefix string) string
- func Uniq(ss *[]string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FoldDup ¶
FoldDup reports a pair of strings from the list that are equal according to strings.EqualFold. It returns "", "" if there are no such strings.
func HasFilePathPrefix ¶
HasFilePathPrefix reports whether the filesystem path s begins with the elements in prefix.
func HasPathPrefix ¶
HasPathPrefix reports whether the slash-separated path s begins with the elements in prefix.
func QuoteGlob ¶ added in v0.5.2
QuoteGlob returns s with all Glob metacharacters quoted. We don't try to handle backslash here, as that can appear in a file path on Windows.
func StringList ¶
StringList flattens its arguments into a single []string. Each argument in args must have type string or []string.
func ToFold ¶
ToFold returns a string with the property that
strings.EqualFold(s, t) iff ToFold(s) == ToFold(t)
This lets us test a large set of strings for fold-equivalent duplicates without making a quadratic number of calls to EqualFold. Note that strings.ToUpper and strings.ToLower do not have the desired property in some corner cases.
func TrimFilePathPrefix ¶ added in v0.1.0
TrimFilePathPrefix returns s without the leading path elements in prefix. If s does not start with prefix (HasFilePathPrefix with the same arguments returns false), TrimFilePathPrefix returns s. If s equals prefix, TrimFilePathPrefix returns "".
Types ¶
This section is empty.