Documentation ¶
Index ¶
- Constants
- func AtoInt64(s string) int64
- func AtoUint(s string) uint
- func AtoUint64(s string) uint64
- func ContainsAnyStrings(haystack string, needles ...string) bool
- func EndsWith(s string, ending string) bool
- func ExtractNumbers(in string) (out string)
- func HasCharType(s string, wantUpper, wantLower, wantDigit, wantPunc, wantSymbol bool) bool
- func HasOnlyLetters(s string) bool
- func If(cond bool, trueVal, falseVal string) string
- func Indent(s string) string
- func JoinContent(sep string, items ...string) string
- func KebabToCamel(s string) string
- func LcFirst(s string) string
- func PasswordString(n int) string
- func RandomString(source string, n int) string
- func SnakeToKebab(s string) string
- func StartsWith(s string, beginning string) bool
- func Title(s string) string
Examples ¶
Constants ¶
const AlphaAll = AlphaLower + AlphaUpper + AlphaNum
const AlphaLower = "abcdefghijklmnopqrstuvwxyz"
const AlphaNum = "0123456789"
const AlphaUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Variables ¶
This section is empty.
Functions ¶
func ContainsAnyStrings ¶ added in v0.13.4
ContainsAnyStrings returns true if the haystack contains any of the needles
func ExtractNumbers ¶ added in v0.7.1
ExtractNumbers returns a string with the digits contained in the given string.
Example ¶
a := ExtractNumbers("a1b2 c3") fmt.Println(a)
Output: 123
func HasCharType ¶ added in v0.19.0
HasCharType returns true if the given string has at least one of all the selected char types.
func HasOnlyLetters ¶ added in v0.7.0
HasOnlyLetters will return false if any of the characters in the string do not pass the unicode.IsLetter test.
func If ¶ added in v0.12.0
If is like the ternary operator ?. It returns the first string on true, and the second on false.
func JoinContent ¶ added in v0.7.0
JoinContent joins strings together with the separator sep. Only strings that are not empty strings are joined.
Example ¶
a := JoinContent("+", "this", "", "that") fmt.Println(a)
Output: this+that
func KebabToCamel ¶ added in v0.2.4
KebabToCamel convert kebab-case words to CamelCase words.
Example ¶
a := KebabToCamel("abc-def") fmt.Println(a)
Output: AbcDef
func PasswordString ¶ added in v0.9.3
PasswordString generates a pseudo random password with the given length using characters that are common in passwords. We attempt to leave out letters that are easily visually confused. Specific letters excluded are lowercase l, upper case I and the number 1, upper case O and the number 0 Also, only easily identifiable and describable symbols are used. It also tries to protect against accidentally creating an easily guessed value by making sure the password has at least one lower-case letter, one upper-case letter, one number, and one symbol. n must be at least 4
func RandomString ¶ added in v0.9.3
RandomString generates a pseudo random string of the given length using the given characters. The distribution is not perfect, but works for general purposes
func SnakeToKebab ¶ added in v0.9.3
SnakeToKebab converts snake_case words to kebab-case words.
Example ¶
a := SnakeToKebab("abc_def") fmt.Println(a)
Output: abc-def
func StartsWith ¶
StartsWith returns true if the string begins with the beginning string.
Types ¶
This section is empty.