Documentation ¶
Index ¶
- Constants
- func ContainsFold(s, substr string) bool
- func DetectBOM(b []byte) (bom string)
- func Format(format string, kwArgs any, posArgs ...any) string
- func HasPrefixFold(s, prefix string) bool
- func HasSuffixFold(s, suffix string) bool
- func IsASCII(str string) bool
- func IsASCIIDigit(str string) bool
- func IsDigit(str string) bool
- func IsLower(str string) bool
- func IsPrintable(str string) bool
- func IsUpper(str string) bool
- func Random(table string, length int) string
- func RandomCrypto(table string, length int) string
- func RandomHex(length int) string
- func Reverse(s string) string
- func SkipBOMReader(rd io.Reader) io.Reader
- func ToCamelCase(in string) string
- func ToLowerCamelCase(in string) string
- func ToSnakeCase(in string) string
- func TrimBOM(b []byte) []byte
Constants ¶
const ( BOM_UTF8 = "\xEF\xBB\xBF" BOM_UTF16_BigEndian = "\xFE\xFF" BOM_UTF16_LittleEndian = "\xFF\xFE" BOM_UTF32_BigEndian = "\x00\x00\xFE\xFF" BOM_UTF32_LittleEndian = "\xFF\xFE\x00\x00" )
Unicode byte order mark (BOM) constants.
Reference: https://en.wikipedia.org/wiki/Byte_order_mark and https://www.unicode.org/faq/utf_bom.html
const ( Digits = "0123456789" HexDigits = "0123456789abcdefABCDEF" OctDigits = "01234567" UpperLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" LowerLetters = "abcdefghijklmnopqrstuvwxyz" Letters = UpperLetters + LowerLetters AlphaDigits = Letters + Digits PasswordSpecial = "!#$%&()*+,-./:;<=>?@[]^_{|}~" )
Variables ¶
This section is empty.
Functions ¶
func ContainsFold ¶
ContainsFold is like strings.Contains but uses Unicode case-folding.
func Format ¶
Format mimics subset features of the python string.format function.
It formats the string using given keyword arguments and positional arguments. kwArgs can be a map[string]any, map[string]string or a struct or a pointer to a struct.
If bracket is needed in string it can be created by escaping (two brackets).
All standard formatting options from fmt work. To specify them, add colon after key name or position number and specify fmt package compatible formatting options. The percent sign is optional. For example:
// returns "3.14, 3.1416" Format("{pi:%.2f}, {pi:.4f}", map[string]any{"pi": math.Pi})
If a replacement is not found in kwArgs and posArgs, the placeholder will be output as the same in the given format.
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 IsASCII ¶
IsASCII returns true if the string is empty or all characters in the string are ASCII, false otherwise.
func IsASCIIDigit ¶
IsASCIIDigit returns true if all characters in the string are in range 0-9 and there is at least one character, false otherwise.
func IsDigit ¶
IsDigit returns true if all characters in the string are digits and there is at least one character, false otherwise
func IsLower ¶
IsLower returns true if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.
func IsPrintable ¶
IsPrintable returns true if all characters in the string are printable or the string is empty, false otherwise.
func IsUpper ¶
IsUpper returns true if all cased characters in the string are uppercase and there is at least one cased character, false otherwise.
func RandomCrypto ¶
RandomCrypto returns a random string of length consisting of characters from table.
func RandomHex ¶
RandomHex returns a random hex string of length consisting of cryptographic-safe random bytes.
func Reverse ¶
Reverse returns a new string of the rune characters from the given string in reverse order.
func SkipBOMReader ¶
SkipBOMReader detects and skips BOM prefix from the given io.Reader. It returns a *bufio.Reader.
func ToCamelCase ¶
ToCamelCase converts the given string to CamelCase.
func ToLowerCamelCase ¶
ToLowerCamelCase converts the given string to lowerCamelCase.
func ToSnakeCase ¶
ToSnakeCase convert the given string to snake case following the Golang format: acronyms are converted to lower-case and preceded by an underscore.
Types ¶
This section is empty.