txt

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: MPL-2.0 Imports: 7 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollapseSpaces

func CollapseSpaces(in string) string

CollapseSpaces removes leading and trailing spaces and reduces any runs of two or more spaces to a single space.

func DigitToValue

func DigitToValue(ch rune) (int, error)

DigitToValue converts a unicode digit into a numeric value.

func DurationToCode

func DurationToCode(duration time.Duration) string

DurationToCode turns a time.Duration into more human-readable text required for code than a simple number of nanoseconds.

func FirstN

func FirstN(s string, n int) string

FirstN returns the first n runes of a string.

func FirstToUpper

func FirstToUpper(in string) string

FirstToUpper converts the first character to upper case.

func FormatDuration

func FormatDuration(duration time.Duration, includeMillis bool) string

FormatDuration formats the duration as either "0:00:00" or "0:00:00.000".

func LastN

func LastN(s string, n int) string

LastN returns the last n runes of a string.

func NaturalLess

func NaturalLess(s1, s2 string, caseInsensitive bool) bool

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

func ParseDuration(duration string) (time.Duration, error)

ParseDuration parses the duration string, as produced by FormatDuration().

func ToCamelCase

func ToCamelCase(in string) string

ToCamelCase converts a string to CamelCase.

func ToSnakeCase

func ToSnakeCase(in string) string

ToSnakeCase converts a string to 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