Documentation
¶
Overview ¶
Package lysstring contains string functions.
Index ¶
- func Camel(s string) (res string)
- func Convert(s, inSep, outSep string, f func(string) string) (res string)
- func DeAlias[T ~string](in []T) (out []string)
- func FirstLower(s string) string
- func FormatBytes(n int64) string
- func IsAscii(s string) bool
- func JoinInts[T constraints.Integer](ints []T, sep string) string
- func Joined(s string) (res string)
- func Kebab(name string) (res string)
- func Pascal(s string) (res string)
- func Rand(n int) string
- func RemoveCharacters(input string, charsToRemove string) string
- func ReplaceAccents(s string) (res string, err error)
- func SafeFileName(name, ext string) string
- func SingleLine(s string) string
- func SingleSpace(s string) string
- func Snake(s string) (res string)
- func StripPunct(s string) string
- func Title(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Camel ¶ added in v0.1.48
Camel removes punctuation, accents, and spaces in s and converts it to camel case My string -> myString
func Convert ¶
Convert changes value separation of s, e.g. from CSV (,) to TSV (|). If inSep is empty, s is split by character.
func FirstLower ¶ added in v0.1.48
FirstLower changes the first character of s to lower case. From https://stackoverflow.com/questions/75988064/make-first-letter-of-string-lower-case-in-golang.
func FormatBytes ¶ added in v0.3.52
func IsAscii ¶ added in v0.1.23
IsAscii returns true if s only contains ASCII chars. From https://stackoverflow.com/questions/53069040/checking-a-string-contains-only-ascii-characters
func JoinInts ¶ added in v0.3.17
func JoinInts[T constraints.Integer](ints []T, sep string) string
JoinInts joins the supplied int slice into a single string separated by sep
func Joined ¶ added in v0.1.48
Joined removes punctuation, accents, and spaces in s and converts it to lower case My string -> mystring
func Kebab ¶ added in v0.1.48
Kebab removes punctuation and accents in s and changes it to lower case with hyphen separation My string -> my-string
func Pascal ¶ added in v0.1.48
Pascal removes punctuation, accents, and spaces in s and changes it to Pascal case My string -> MyString
func Rand ¶ added in v0.3.33
Rand creates a random string of length n. From https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go, but uses rand/v2 patterns.
func RemoveCharacters ¶ added in v0.1.14
RemoveCharacters returns input with the chars in charsToRemove removed.
func ReplaceAccents ¶ added in v0.1.23
ReplaceAccents replaces accent characters such as "é" with their non-accented equivalents such as "e". Contains special handling for German accents. From https://twin.sh/articles/33/remove-accents-from-characters-in-go.
func SafeFileName ¶ added in v0.3.36
SafeFileName returns a version of name that is safe to use as a file name, with ext appended. It replaces chars that are not letters, digits, hyphens, underscores, or periods with underscores, and trims leading and trailing periods and underscores. If the resulting name is empty, it returns "file" + ext.
func SingleLine ¶ added in v0.1.49
SingleLine removes tabs and excess line breaks from s. "a\n\n\tb\n" -> "a\nb". From https://stackoverflow.com/questions/35360080/golang-idiomatic-way-to-remove-a-blank-line-from-a-multi-line-string.
func SingleSpace ¶ added in v0.1.49
SingleSpace removes excess tabs and spaces from s. " a b " -> "a b". From https://stackoverflow.com/questions/37290693/how-to-remove-redundant-spaces-whitespace-from-a-string-in-golang.
func Snake ¶ added in v0.1.48
Snake removes punctuation and accents in s and changes it to lower case with underscore separation My string -> my_string
func StripPunct ¶ added in v0.3.33
StripPunct removes Unicode punctuation characters from s.
Types ¶
This section is empty.