strs

package
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Intersection

func Intersection(one []string, two []string) []string

Intersection return the intersection between one and two, sorted and dropping empty strings.

func IsCamelCase

func IsCamelCase(s string) bool

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

func IsCapitalized(s string) bool

IsCapitalized returns true if is not empty and the first letter is an uppercase character.

func IsLowerSnakeCase

func IsLowerSnakeCase(s string) bool

IsLowerSnakeCase returns true if s only contains lowercase letters, digits, and/or underscores. s MUST NOT begin or end with an underscore.

func IsLowercase

func IsLowercase(s string) bool

IsLowercase returns true if s is not empty and is all lowercase.

func IsUpperSnakeCase

func IsUpperSnakeCase(s string) bool

IsUpperSnakeCase returns true if s only contains uppercase letters, digits, and/or underscores. s MUST NOT begin or end with an underscore.

func IsUppercase

func IsUppercase(s string) bool

IsUppercase returns true if s is not empty and is all uppercase.

func MapToSortedSlice added in v1.11.1

func MapToSortedSlice(m map[string]struct{}) []string

MapToSortedSlice returns the sorted keys of m.

func SortUniq added in v1.11.1

func SortUniq(s []string) []string

SortUniq returns the unique sorted non-empty values of s.

func SortUniqModify added in v1.11.1

func SortUniqModify(s []string, modifier func(string) string) []string

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

func SplitCamelCaseWord(s string) []string

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

func SplitSnakeCaseWord(s string) []string

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

func ToLowerSnakeCase(s string) string

ToLowerSnakeCase converts s to lower_snake_case.

func ToUpperCamelCase added in v1.11.1

func ToUpperCamelCase(s string) string

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

func ToUpperSnakeCase(s string) string

ToUpperSnakeCase converts s to UPPER_SNAKE_CASE.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL