package strutil
import "go4.org/strutil"
Package strutil contains string and byte processing functions.
Index ¶
- func AppendSplitN(dst []string, s, sep string, n int) []string
- func ContainsFold(s, substr string) bool
- func HasPrefixFold(s, prefix string) bool
- func HasSuffixFold(s, suffix string) bool
- func IsPlausibleJSON(s string) bool
- func ParseUintBytes(s []byte, base int, bitSize int) (n uint64, err error)
- func RegisterCommonString(s ...string)
- func StringFromBytes(v []byte) string
Functions ¶
func AppendSplitN ¶
AppendSplitN is like strings.SplitN but appends to and returns dst. Unlike strings.SplitN, an empty separator is not supported. The count n 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
func ContainsFold ¶
ContainsFold is like strings.Contains but uses Unicode case-folding.
func HasPrefixFold ¶
HasPrefixFold is like strings.HasPrefix but uses Unicode case-folding, matching case insensitively.
func HasSuffixFold ¶
HasSuffixFold is like strings.HasSuffix but uses Unicode case-folding, matching case insensitively.
func IsPlausibleJSON ¶
IsPlausibleJSON reports whether s likely contains a JSON object, without actually parsing it. It's meant to be a light heuristic.
func ParseUintBytes ¶
ParseUintBytes is like strconv.ParseUint, but using a []byte.
func RegisterCommonString ¶
func RegisterCommonString(s ...string)
RegisterCommonString adds common strings to the interned string table. This should be called during init from the main goroutine, not later at runtime.
func StringFromBytes ¶
StringFromBytes returns string(v), minimizing copies for common values of v as previously registered with RegisterCommonString.
Source Files ¶
intern.go strconv.go strutil.go
- Version
- v0.0.0-20230225012048-214862532bf5 (latest)
- Published
- Feb 25, 2023
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 1 month ago –
Tools for package owners.