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 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 MapToSortedSlice(m map[string]struct{}) []string
- func SortUniq(s []string) []string
- func SortUniqModify(s []string, modifier func(string) string) []string
- func SplitCamelCaseWord(s string) []string
- func SplitSnakeCaseWord(s string) []string
- func ToLowerSnakeCase(s string) string
- func ToUpperCamelCase(s string) string
- func ToUpperSnakeCase(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 MapToSortedSlice ¶ added in v1.11.1
MapToSortedSlice returns the sorted keys of m.
func SortUniqModify ¶ added in v1.11.1
SortUniqModify returns the unique sorted non-empty values of s. If modifier is not nil, modifier will be applied to each element in s.
func SplitCamelCaseWord ¶ added in v1.11.1
SplitCamelCaseWord splits a CamelCase word into its parts.
If s is empty, returns nil. If s is not CamelCase, returns nil.
func SplitSnakeCaseWord ¶ added in v1.11.1
SplitSnakeCaseWord splits a snake_case word into its parts.
If s is empty, returns nil. If s is not snake_case, returns nil.
func ToLowerSnakeCase ¶ added in v1.11.1
ToLowerSnakeCase converts s to lower_snake_case.
func ToUpperCamelCase ¶ added in v1.11.1
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.