Documentation ¶
Overview ¶
Package xstrings provides extended utility functions for strings
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Or ¶
Or returns the first element of string array which is not empty
Example ¶
fmt.Println(Or("a", "b")) fmt.Println(Or("", "b"))
Output: a b
func SplitAndTrim ¶
SplitAndTrim is like strings.Split but spaces in each of item are trimmed
Example ¶
fmt.Println(SplitAndTrim("a, b, c ,d,,f,", ","))
Output: [a b c d f]
func SplitAndTrimAsMap ¶
SplitAndTrimAsMap is like SplitAndTrim but returns an map[string]bool where the map key is the string flagment included in
Example ¶
m := SplitAndTrimAsMap("a, b, c ,d,,f,", ",") _, ok := m["a"] _, not := m["z"] fmt.Println(ok, not)
Output: true false
func ToSnakeCase ¶
ToSnakeCase converts the string to the one by snake case.
Example ¶
fmt.Println( ToSnakeCase("A"), ToSnakeCase("FooBar"), ToSnakeCase("APIDoc"), ToSnakeCase("OK"), ToSnakeCase("IsOK"), ToSnakeCase("camelCase"), )
Output: a foo_bar api_doc ok is_ok camel_case
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.