Documentation ¶
Overview ¶
Package strs contains common string manipulation functionality.
This functionality is not really centralized anywhere in Golang OSS world, and there are some specific requirements we have. This is used mostly in the lint package.
Index ¶
- func DedupeSort(s []string, modifier func(string) string) []string
- func Intersection(one []string, two []string) []string
- func IsCamelCase(s string) bool
- func IsCapitalized(s string) bool
- func IsLowerSnakeCase(s string) bool
- func IsLowercase(s string) bool
- func IsUpperSnakeCase(s string) bool
- func IsUppercase(s string) bool
- func ToUpperCamelCase(s string) string
- func ToUpperSnakeCase(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DedupeSort ¶
DedupeSort returns s with no duplicates and no empty strings, sorted. If modifier is not nil, modifier will be applied to each element in s.
func Intersection ¶
Intersection return the intersection between one and two, sorted and dropping empty strings.
func IsCamelCase ¶
IsCamelCase returns false if s is empty or contains any character that is not between 'A' and 'Z', 'a' and 'z', '0' and '9', or in extraRunes. It does not care about lowercase or uppercase.
func IsCapitalized ¶
IsCapitalized returns true if is not empty and the first letter is an uppercase character.
func IsLowerSnakeCase ¶
IsLowerSnakeCase returns true if s only contains lowercase letters, digits, and/or underscores. s MUST NOT begin or end with an underscore.
func IsLowercase ¶
IsLowercase returns true if s is not empty and is all lowercase.
func IsUpperSnakeCase ¶
IsUpperSnakeCase returns true if s only contains uppercase letters, digits, and/or underscores. s MUST NOT begin or end with an underscore.
func IsUppercase ¶
IsUppercase returns true if s is not empty and is all uppercase.
func ToUpperCamelCase ¶ added in v0.4.0
ToUpperCamelCase converts s to UpperCamelCase.
We use this for files, so any delimiter (_, -, or space) is used to denote word boundaries, but we trim spaces from the beginning and end of the string first.
If a letter is uppercase, it will stay uppercase regardless, this is for cases of abbreviations.
func ToUpperSnakeCase ¶
ToUpperSnakeCase converts s to UPPER_SNAKE_CASE.
Types ¶
This section is empty.