strs

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2018 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 DedupeSort

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

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

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 ToUpperCamelCase added in v0.4.0

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