util

package
v0.0.0-...-13c19bd Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NumDigits

func NumDigits(n int) int

NumDigits returns the number of decimal digits in uint n.

func PrivateTitle

func PrivateTitle(s string) string

PrivateTitle is like strings.Title(), except the first Unicode letter in s is mapped to its Unicode lower case.

Types

type Newliner

type Newliner []string

Newliner represents a string list that is aggregated as a sequence of Go source code lines

func (*Newliner) Add

func (nl *Newliner) Add(ln string) *Newliner

Add appends a new line to receiver.

func (*Newliner) Addf

func (nl *Newliner) Addf(fm string, ar ...interface{}) *Newliner

Addf appends a new line with given printf-style format and args to receiver.

type Uniquer

type Uniquer struct {
	// contains filtered or unexported fields
}

Uniquer represents a collection of unique strings.

func NewUniquer

func NewUniquer(suffix string) *Uniquer

NewUniquer creates a new collection of unique strings. Duplicate strings will be distinguished by having suffix appended to it

func (*Uniquer) Add

func (u *Uniquer) Add(key string) string

Add adds a new string to the collection. If the string already exists, it is appended with u.Suffix repeatedly until it is unique. Uses the original string value this method was called with as auxiliary value. Returns the resulting unique name.

func (*Uniquer) AddValue

func (u *Uniquer) AddValue(key, val string) string

AddValue adds a new string to the collection like Add, but with a specific auxiliary value that can be later retrieved with Values or JoinValues. Returns the resulting unique name.

func (*Uniquer) Join

func (u *Uniquer) Join(sep string) string

Join concatenates all of the unique strings in u, separated by string sep, and sorted by the index or order in which the string was added.

func (*Uniquer) JoinValues

func (u *Uniquer) JoinValues(sep string) string

JoinValues concatenates all of values associated with the unique strings in u, separated by string sep, and sorted by the index or order in which the string was added.

func (*Uniquer) Strings

func (u *Uniquer) Strings() []string

Strings returns the unique strings in u, sorted by the index or order in which the string was added.

func (*Uniquer) Values

func (u *Uniquer) Values() []string

Values returns the values associated with each unique string in u, sorted by the index or order in which the string was added.

Jump to

Keyboard shortcuts

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