Documentation ¶
Index ¶
- Variables
- func ContainsAnyRangeTable(s string, rangeTabs ...*unicode.RangeTable) bool
- func ContainsAsciiVisual(s string) bool
- func ContainsOnlyAsciiVisual(s string) bool
- func ContainsOnlyRangeTable(s string, rangeTabs ...*unicode.RangeTable) bool
- func ContainsRuneAnyFunc(s string, f func(rune) bool) bool
- func ContainsRuneOnlyFunc(s string, f func(rune) bool) bool
- func DarwinCase(s string, seps ...rune) string
- func DotCase(s string, seps ...rune) string
- func DottedSlice(elem ...string) string
- func ExtractFirstRune(s string) (rune, string)
- func JoinGenerator(sep string, mapping func(s string) string) func(r string) string
- func JoinRepeat(s string, sep string, n int) string
- func KebabCase(s string, seps ...rune) string
- func LowerCamelCase(s string, seps ...rune) string
- func LowerCamelCaseSlice(elem ...string) string
- func LowerCaseWithUnderscores(s string, seps ...rune) string
- func MapLeading(mapping func(rune) rune, s string) string
- func PadLeft(s string, pad string, n int) string
- func PadRight(s string, pad string, n int) string
- func SliceCombine(ss ...[]string) []string
- func SliceContains(ss []string, tt ...string) bool
- func SliceEqual(s, t []string) bool
- func SliceEqualFold(s, t []string) bool
- func SliceTrim(ss []string, tt ...string) []string
- func SliceTrimEmpty(ss ...string) []string
- func SliceTrimFunc(ss []string, f func(s string) bool) []string
- func SliceUnique(s ...string) []string
- func SnakeCase(s string, seps ...rune) string
- func SplitPrefixNumber(s string) []string
- func StudlyCapsCase(upperCase unicode.SpecialCase, s string) string
- func StudlyCapsConsonantUpperCase(s string) string
- func StudlyCapsVowelUpperCase(s string) string
- func ToLowerLeading(s string) string
- func ToUpperLeading(s string) string
- func TransformCase(s string, join func(r string) string, seps ...rune) string
- func TrimPrefixComplex(s string) string
- func TrimPrefixFloat(s string) string
- func TrimPrefixInteger(s string) string
- func TrimPrefixNumber(s string) string
- func UpperCamelCase(s string, seps ...rune) string
- func UpperCamelCaseSlice(elem ...string) string
- func ValueOrDefault(value, def string) string
Constants ¶
This section is empty.
Variables ¶
var ( PascalCase = UpperCamelCase CapitalizedWordsCase = UpperCamelCase CapWordsCase = UpperCamelCase CapitalizedWords = UpperCamelCase // SentenceCase is a mixed-case style in which the first word of the sentence is capitalised, // as well as proper nouns and other words as required by a more specific rule. // This is generally equivalent to the baseline universal standard of formal English orthography. // https://en.wikipedia.org/wiki/Letter_case#Sentence_Case // "The quick brown fox jumps over the lazy dog" SentenceCase = strings.Title // TitleCase capitalises all words but retains the spaces between them // https://en.wikipedia.org/wiki/Letter_case#Title_Case // "The Quick Brown Fox Jumps over the Lazy Dog" TitleCase = strings.ToTitle // AllCapsCase is an unicase style with capital letters only. // https://en.wikipedia.org/wiki/Letter_case#All_caps // "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG" AllCapsCase = strings.ToUpper AllUpperCase = AllCapsCase // AllLowercase is an unicase style with no capital letters. // https://en.wikipedia.org/wiki/Letter_case#All_lowercase // "the quick brown fox jumps over the lazy dog" AllLowercase = strings.ToLower )
var ( DromedaryCase = LowerCamelCase // Some people and organizations, notably Microsoft, use the term camel case only for lower camel case. // Pascal case means only upper camel case. CamelCase = LowerCamelCase // MixedCase for lower camel case in Python MixedCase = LowerCamelCase )
var ( // lowercase LowerCase = strings.ToLower )
Functions ¶
func ContainsAnyRangeTable ¶ added in v0.0.75
func ContainsAnyRangeTable(s string, rangeTabs ...*unicode.RangeTable) bool
ContainsAnyRangeTable reports whether the string contains any rune in any of the specified table of ranges.
func ContainsAsciiVisual ¶ added in v0.0.75
ContainsAsciiVisual reports whether the string contains any rune in visual ascii code, that is [0x21, 0x7E].
func ContainsOnlyAsciiVisual ¶ added in v0.0.75
ContainsAsciiVisual reports whether the string contains only rune in visual ascii code, that is [0x21, 0x7E].
func ContainsOnlyRangeTable ¶ added in v0.0.75
func ContainsOnlyRangeTable(s string, rangeTabs ...*unicode.RangeTable) bool
ContainsOnlyRangeTable reports whether the string contains only rune in all of the specified table of ranges.
func ContainsRuneAnyFunc ¶ added in v0.0.75
ContainsRuneAnyFunc reports whether any of the Unicode code point r satisfying f(r) is within s.
func ContainsRuneOnlyFunc ¶ added in v0.0.75
ContainsRuneOnlyFunc reports whether all of the Unicode code point r satisfying f(r) is within s.
func DarwinCase ¶
DarwinCase returns the DarwinCased name. Darwin case uses underscores between words with initial uppercase letters, as in "Sample_Type" In short, _my_field_name_2 becomes X_My_Field_Name_2. see https://en.wikipedia.org/wiki/Camel_case
func DotCase ¶
DotCase returns the KebabCased name. In short, _my_field_name_2 becomes x.my.field.name.2.
func DottedSlice ¶
DottedSlice turns a sliced name into a dotted name.
func ExtractFirstRune ¶
func JoinGenerator ¶
JoinGenerator supplies sep between strings step by step, with mapping if consists [r0,r1,r2] -> "r0'""sep""r1'""sep""r2'"
func JoinRepeat ¶ added in v0.0.68
JoinRepeat behaves like strings.Join([]string{s,...,s}, sep)
func KebabCase ¶
KebabCase returns the KebabCased name. In short, _my_field_name_2 becomes x-my-field-name-2. "the-quick-brown-fox-jumps-over-the-lazy-dog"
func LowerCamelCase ¶
LowerCamelCase returns the CamelCased name by lowercase uppercase letter. In short, _my_field_name_2 becomes xMyFieldName_2. "theQuickBrownFoxJumpsOverTheLazyDog"
func LowerCamelCaseSlice ¶
LowerCamelCaseSlice is like LowerCamelCase, but the argument is a slice of strings to be joined with "_".
func LowerCaseWithUnderscores ¶
lower_case_with_underscores
func MapLeading ¶
MapLeading returns a copy of the string s with its first characters modified according to the mapping function. If mapping returns a negative value, the character is dropped from the string with no replacement.
func PadLeft ¶ added in v0.0.83
PadLeft returns s padded to length n, padded left with repeated pad return s directly if pad is empty padding s with {{pad}} and spaces(less than len(pad)) as a prefix, as [pad]...[pad][space]...[space][s]
func PadRight ¶ added in v0.0.83
PadRight returns s padded to length n, padded right with repeated pad return s directly if pad is empty padding s with {{pad}} and spaces(less than len(pad)) as a suffix, as [s][space]...[space][pad]...[pad]
func SliceCombine ¶ added in v0.0.72
SliceCombine combine elements to a new slice.
func SliceContains ¶
SliceContains reports whether any t in tt is within ss.
func SliceEqual ¶ added in v0.0.71
SliceEqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under Unicode case-folding, which is a more general form of case-sensitivity.
func SliceEqualFold ¶ added in v0.0.71
SliceEqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under Unicode case-folding, which is a more general form of case-insensitivity.
func SliceTrimEmpty ¶ added in v0.0.71
SliceTrimEmpty trim empty columns
func SliceTrimFunc ¶ added in v0.0.71
SliceTrimFunc returns a slice of the string ss satisfying f(c) removed.
func SliceUnique ¶
SliceUnique returns the given string slice with unique values.
func SnakeCase ¶
SnakeCase returns the SnakeCased name. In short, _my_field_name_2 becomes x_my_field_name_2. seps will append '_' if len(seps) == 0 "the_quick_brown_fox_jumps_over_the_lazy_dog"
func SplitPrefixNumber ¶
SplitPrefixNumber slices s into number prefix and unparsed and returns a slice of those substrings. If s does not start with number, SplitPrefixNumber returns a slice of length 1 whose only element is s.
func StudlyCapsCase ¶
func StudlyCapsCase(upperCase unicode.SpecialCase, s string) string
Studly caps is a form of text notation in which the capitalization of letters varies by some pattern, or arbitrarily, usually also omitting spaces between words and often omitting some letters, for example, StUdLyCaPs or STuDLyCaPS. Such patterns are identified by many users, ambiguously, as camel case. The typical alternative is to just replace spaces with underscores (as in snake case). Messages may be hidden in the capital and lower-case letters such as "ShoEboX" which spells "SEX" in capitals and "hobo" in lower-case. https://en.wikipedia.org/wiki/Studly_caps "tHeqUicKBrOWnFoXJUmpsoVeRThElAzydOG" "THiS iS aN eXCePTioNaLLy eLiTe SeNTeNCe"
func StudlyCapsConsonantUpperCase ¶
"THeQuiCKBRoWNFoXJuMPSoVeRTHeLaZYDoG"
func StudlyCapsVowelUpperCase ¶
"thEqUIckbrOwnfOxjUmpsOvErthElAzydOg"
func ToLowerLeading ¶
ToLowerLeading returns s with it's first Unicode letter mapped to their lower case.
func ToUpperLeading ¶
ToUpperLeading returns s with it's first Unicode letter mapped to their upper case.
func TransformCase ¶
TransformCase Splits and apply map on every splits
func TrimPrefixComplex ¶
TrimPrefixComplex returns s without the leading complex prefix string. If s doesn't start with complex prefix, s is returned unchanged.
func TrimPrefixFloat ¶
TrimPrefixFloat returns s without the leading float prefix string. If s doesn't start with float prefix, s is returned unchanged.
func TrimPrefixInteger ¶
TrimPrefixInteger returns s without the leading integer prefix string. If s doesn't start with integer prefix, s is returned unchanged.
func TrimPrefixNumber ¶
TrimPrefixNumber returns s without the leading number prefix string. If s doesn't start with number prefix, s is returned unchanged.
func UpperCamelCase ¶
UpperCamelCase returns the CamelCased name by initial uppercase letter. If there is an interior split rune such as an underscore followed by a lower case letter, drop the underscore and convert the letter to upper case. There is a remote possibility of this rewrite causing a name collision, but it's so remote we're prepared to pretend it's nonexistent - since the C++ JoinGenerator lowercases names, it's extremely unlikely to have two fields with different capitalizations. In short, _my_field_name_2 becomes XMyFieldName_2. "TheQuickBrownFoxJumpsOverTheLazyDog"
func UpperCamelCaseSlice ¶
UpperCamelCaseSlice is like UpperCamelCase, but the argument is a slice of strings to be joined with "_".
func ValueOrDefault ¶ added in v0.0.67
Return value if nonempty, def otherwise.
Types ¶
This section is empty.