Documentation ¶
Index ¶
- 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 ToSnakeCase(in string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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().
Types ¶
This section is empty.