Documentation ¶
Overview ¶
Package stringx provides extra helpers to work with string.
Index ¶
- Variables
- func CamelCaseToUnderscore(s string) string
- func CapitalizeEachWord(s string) string
- func RandomPassword(length int) (string, error)
- func RandomString(length int) (string, error)
- func RandomStringIgnoreError(length int) string
- func Slugify(s string) (string, error)
- func TrimExtraWhiteSpacesInOut(s string) string
- func UnderscoreToLowerCamelCase(s string, t language.Tag) string
- func UnderscoreToUpperCamelCase(s string, t language.Tag) string
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptySlug = errors.New("stringx: empty slug") ErrEmptyString = errors.New("stringx: empty string") ErrGenerateRandomString = errors.New("stringx: failed to generate random string") ErrInvalidLength = errors.New("stringx: invalid length") ErrInvalidInput = errors.New("stringx: invalid input") )
Functions ¶
func CamelCaseToUnderscore ¶
CamelCaseToUnderscore returns camel case string s in underscore style. For example: FooBar -> foo_bar
func CapitalizeEachWord ¶
CapitalizeEachWord returns string s with each word capitalized. This function works on ASCII letters only.
func RandomPassword ¶
RandomPassword returns a random password for the given length.
func RandomString ¶
RandomString returns a string of random characters of length, using randomStringSource as the source for the string.
func RandomStringIgnoreError ¶
RandomStringIgnoreError is a convenient method for RandomString.
func Slugify ¶
Slugify returns a string with all non-english letters and non-digits with '-'. For example, 'hello world' -> 'hello-world'.
func TrimExtraWhiteSpacesInOut ¶ added in v2.1.0
TrimExtraWhiteSpacesInOut returns a string with extra whitespaces surrounded each words removed. For example: " foo bar alice smith" -> "foo bar alice smith"
func UnderscoreToLowerCamelCase ¶
UnderscoreToLowerCamelCase returns the underscore string s in language t in lower camel case. For example: foo_bar -> fooBar
Types ¶
This section is empty.