Documentation ¶
Index ¶
- Constants
- Variables
- func EraseAnyWSs(s string) string
- func HasOrderPrefix(s string) bool
- func IsDigitHeavy(s string) bool
- func Launch(cmd string, args ...string) (err error)
- func LaunchEditor(editor string) (content []byte, err error)
- func LaunchEditorWith(editor string, filename string) (content []byte, err error)
- func Max(a, b int) int
- func Min(a, b int) int
- func ParseComplex(s string) (v complex128)
- func ParseComplexX(s string) (v complex128, err error)
- func PressAnyKeyToContinue(in io.Reader, msg ...string) (input string)
- func PressEnterToContinue(in io.Reader, msg ...string) (input string)
- func RandomStringPure(length int) (result string)
- func ReadPassword() (text string, err error)
- func Soundex(s string) (snd4 string)
- func StripOrderPrefix(s string) string
- func StripPrefix(s, p string) string
- func StripQuotes(s string) string
- type DistanceOption
- type StringDistance
Constants ¶
const StringMetricFactor = 100000000000
StringMetricFactor for JaroWinklerDistance algorithm
Variables ¶
var SavedOsArgs []string
SavedOsArgs is a copy of os.Args, just for testing
Functions ¶
func EraseAnyWSs ¶
EraseAnyWSs eats any whitespaces inside the giving string s.
func HasOrderPrefix ¶
HasOrderPrefix tests whether an order prefix is present or not. An order prefix is a dotted string with multiple alphabet and digit. Such as: "zzzz.", "0001.", "700.", "A1." ...
func IsDigitHeavy ¶
IsDigitHeavy tests if the whole string is digit
func LaunchEditor ¶
LaunchEditor launches the specified editor
func LaunchEditorWith ¶
LaunchEditorWith launches the specified editor with a filename
func ParseComplex ¶
func ParseComplex(s string) (v complex128)
ParseComplex converts a string to complex number.
Examples:
c1 := cmdr.ParseComplex("3-4i") c2 := cmdr.ParseComplex("3.13+4.79i")
func ParseComplexX ¶
func ParseComplexX(s string) (v complex128, err error)
ParseComplexX converts a string to complex number. If the string is not valid complex format, return err not nil.
Examples:
c1 := cmdr.ParseComplex("3-4i") c2 := cmdr.ParseComplex("3.13+4.79i")
func PressAnyKeyToContinue ¶
PressAnyKeyToContinue lets program pause and wait for user's ANY key press in console/terminal
func PressEnterToContinue ¶
PressEnterToContinue lets program pause and wait for user's ENTER key press in console/terminal
func RandomStringPure ¶
RandomStringPure generate a random string with length specified.
func ReadPassword ¶
ReadPassword reads the password from stdin with safe protection
func StripOrderPrefix ¶
StripOrderPrefix strips the prefix string fragment for sorting order. see also: Command.Group, Flag.Group, ... An order prefix is a dotted string with multiple alphabet and digit. Such as: "zzzz.", "0001.", "700.", "A1." ...
func StripPrefix ¶
StripPrefix strips the prefix 'p' from a string 's'
func StripQuotes ¶
StripQuotes strips single or double quotes around a string.
Types ¶
type DistanceOption ¶
type DistanceOption func(StringDistance)
DistanceOption is a functional options prototype
func JWWithThreshold ¶
func JWWithThreshold(threshold float64) DistanceOption
JWWithThreshold sets the threshold for Jaro-Winkler algorithm.
type StringDistance ¶
type StringDistance interface {
Calc(s1, s2 string, opts ...DistanceOption) (distance int)
}
StringDistance is an interface for string metric. A string metric is a metric that measures distance between two strings. In most case, it means that the edit distance about those two strings. This is saying, it is how many times are needed while you were modifying string to another one, note that inserting, deleting, substing one character means once.
func JaroWinklerDistance ¶
func JaroWinklerDistance(opts ...DistanceOption) StringDistance
JaroWinklerDistance returns an calculator for two strings distance metric, with Jaro-Winkler algorithm.