Documentation ¶
Index ¶
- Variables
- func CollapseSpaces(in string) string
- func DigitToValue(ch rune) (int, error)
- func DurationToCode(duration time.Duration) string
- func FirstN(s string, n int) string
- func FirstToUpper(in string) string
- func FormatDuration(duration time.Duration, includeMillis bool) string
- func LastN(s string, n int) string
- func NaturalLess(s1, s2 string, caseInsensitive bool) bool
- func ParseDuration(duration string) (time.Duration, error)
- func ToCamelCase(in string) string
- func ToCamelCaseWithExceptions(in string, exceptions *AllCaps) string
- func ToSnakeCase(in string) string
- type AllCaps
- type RuneReader
Constants ¶
This section is empty.
Variables ¶
var StdAllCaps = MustNewAllCaps("acl", "api", "ascii", "cpu", "css", "dns",
"eof", "guid", "html", "http", "https", "id", "ip", "json", "lhs", "qps",
"ram", "rhs", "rpc", "sla", "smtp", "sql", "ssh", "tcp", "tls", "ttl",
"udp", "ui", "uid", "uuid", "uri", "url", "utf8", "vm", "xml", "xmpp",
"xsrf", "xss")
StdAllCaps provides the standard list of words that golint expects to be capitalized, found in the variable 'commonInitialisms' in https://github.com/golang/lint/blob/master/lint.go
Functions ¶
func CollapseSpaces ¶
CollapseSpaces removes leading and trailing spaces and reduces any runs of two or more spaces to a single space.
func DigitToValue ¶
DigitToValue converts a unicode digit into a numeric value.
func DurationToCode ¶
DurationToCode turns a time.Duration into more human-readable text required for code than a simple number of nanoseconds.
func FirstToUpper ¶
FirstToUpper converts the first character to upper case.
func FormatDuration ¶
FormatDuration formats the duration as either "0:00:00" or "0:00:00.000".
func NaturalLess ¶
NaturalLess compares two strings using natural ordering. This means that "a2" < "a12".
Non-digit sequences and numbers are compared separately. The former are compared bytewise, while the latter are compared numerically (except that the number of leading zeros is used as a tie-breaker, so "2" < "02").
Limitations:
- only ASCII digits (0-9) are considered.
Original algorithm:
https://github.com/fvbommel/util/blob/master/sortorder/natsort.go
func ParseDuration ¶
ParseDuration parses the duration string, as produced by FormatDuration().
func ToCamelCaseWithExceptions ¶ added in v1.1.5
ToCamelCaseWithExceptions converts a string to CamelCase, but forces certain words to all caps.
Types ¶
type AllCaps ¶ added in v1.1.5
type AllCaps struct {
// contains filtered or unexported fields
}
AllCaps holds information for transforming text with ToCamelCaseWithExceptions.
func MustNewAllCaps ¶ added in v1.1.5
MustNewAllCaps takes a list of words that should be all uppercase when part of a camel-cased string. Failure to create the AllCaps object causes the program to exit.
func NewAllCaps ¶ added in v1.1.5
NewAllCaps takes a list of words that should be all uppercase when part of a camel-cased string.
type RuneReader ¶ added in v1.1.5
RuneReader implements io.RuneReader