Documentation ¶
Index ¶
- Constants
- func CamelToDash(s string) string
- func CamelToSnake(s string) string
- func DashToCamel(s string) string
- func DashToPascal(s string) string
- func GetOrDefault(def string, args ...string) string
- func PascalToDash(s string) string
- func PascalToSnake(s string) string
- func SnakeToCamel(s string) string
- func SnakeToPascal(s string) string
- func ToTitle(s string) string
- type String
- func (s String) Contains(substr string) bool
- func (s String) ContainsAny(chars string) bool
- func (s String) ContainsRune(r rune) bool
- func (s String) Count(sep string) int
- func (s String) EqualFold(t string) bool
- func (s String) Fields() []string
- func (s String) FieldsFunc(f func(rune) bool) []string
- func (s String) HasPrefix(prefix string) bool
- func (s String) HasSuffix(suffix string) bool
- func (s String) Index(sep string) int
- func (s String) IndexAny(chars string) int
- func (s String) IndexByte(c byte) int
- func (s String) IndexFunc(f func(rune) bool) int
- func (s String) IndexRune(r rune) int
- func (s String) LastIndex(sep string) int
- func (s String) LastIndexAny(chars string) int
- func (s String) LastIndexByte(c byte) int
- func (s String) LastIndexFunc(f func(rune) bool) int
- func (s String) Map(mapping func(rune) rune) String
- func (s String) NewReader() *strings.Reader
- func (s String) Repeat(count int) String
- func (s String) Replace(old, new string, n int) String
- func (s String) S() string
- func (s String) Split(sep string) []string
- func (s String) SplitAfter(sep string) []string
- func (s String) SplitAfterN(sep string, n int) []string
- func (s String) SplitN(sep string, n int) []string
- func (s String) Title() String
- func (s String) ToLower() String
- func (s String) ToLowerSpecial(c unicode.SpecialCase) String
- func (s String) ToTitle() String
- func (s String) ToTitleSpecial(c unicode.SpecialCase) String
- func (s String) ToUpper() String
- func (s String) ToUpperSpecial(c unicode.SpecialCase) String
- func (s String) Trim(cutset string) String
- func (s String) TrimLeft(cutset string) String
- func (s String) TrimPrefix(prefix string) String
- func (s String) TrimRight(cutset string) String
- func (s String) TrimSpace() String
- func (s String) TrimSuffix(suffix string) String
- type StringBuilder
- func (s *StringBuilder) Append(args ...string) *StringBuilder
- func (s *StringBuilder) AppendInt(i ...int) *StringBuilder
- func (s *StringBuilder) AppendLine(lines ...string) *StringBuilder
- func (s *StringBuilder) AppendLinef(format string, args ...interface{}) *StringBuilder
- func (s *StringBuilder) AppendObj(objs ...interface{}) *StringBuilder
- func (s *StringBuilder) AppendRune(char rune) *StringBuilder
- func (s *StringBuilder) Appendf(format string, args ...interface{}) *StringBuilder
- func (s *StringBuilder) Br() *StringBuilder
- func (s *StringBuilder) Build() string
- func (s *StringBuilder) IsEmpty() bool
- Bugs
Constants ¶
const LineBreak = "\n"
LineBreak indicates the value to use as line break
Variables ¶
This section is empty.
Functions ¶
func CamelToDash ¶
CamelToDash converts CamelCase to dash-separated-string
func CamelToSnake ¶
CamelToSnake converts CamelCase to snake_case.
func DashToCamel ¶
DashToCamel converts a dash-separated-string to CamelCase
func DashToPascal ¶
DashToCamel converts a dash-separated-string to CamelCase
func GetOrDefault ¶
GetOrDefault is a helper for variadic arguments when used as single optional input value in a variadic function.
func PascalToDash ¶
func PascalToSnake ¶
CamelToSnake converts CamelCase to snake_case.
func SnakeToCamel ¶
SnakeToCamel converts snake_case to CamelCase
func SnakeToPascal ¶
SnakeToCamel converts snake_case to CamelCase
Types ¶
type String ¶
type String struct {
// contains filtered or unexported fields
}
func (String) ContainsAny ¶
ContainsAny reports whether any Unicode code points in chars are within s.
func (String) ContainsRune ¶
ContainsRune reports whether the Unicode code point r is within s.
func (String) Count ¶
Count counts the number of non-overlapping instances of sep in s. If sep is an empty string, Count returns 1 + the number of Unicode code points in s.
func (String) EqualFold ¶
EqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under Unicode case-folding.
func (String) Fields ¶
Fields splits the string s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning an array of substrings of s or an empty list if s contains only white space.
func (String) FieldsFunc ¶
FieldsFunc splits the string s at each run of Unicode code points c satisfying f(c) and returns an array of slices of s. If all code points in s satisfy f(c) or the string is empty, an empty slice is returned. FieldsFunc makes no guarantees about the order in which it calls f(c). If f does not return consistent results for a given c, FieldsFunc may crash.
func (String) Index ¶
Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
func (String) IndexAny ¶
IndexAny returns the index of the first instance of any Unicode code point from chars in s, or -1 if no Unicode code point from chars is present in s.
func (String) IndexByte ¶
IndexByte returns the index of the first instance of c in s, or -1 if c is not present in s.
func (String) IndexFunc ¶
IndexFunc returns the index into s of the first Unicode code point satisfying f(c), or -1 if none do.
func (String) IndexRune ¶
IndexRune returns the index of the first instance of the Unicode code point r, or -1 if rune is not present in s. If r is utf8.RuneError, it returns the first instance of any invalid UTF-8 byte sequence.
func (String) LastIndex ¶
LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s.
func (String) LastIndexAny ¶
LastIndexAny returns the index of the last instance of any Unicode code point from chars in s, or -1 if no Unicode code point from chars is present in s.
func (String) LastIndexByte ¶
LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.
func (String) LastIndexFunc ¶
LastIndexFunc returns the index into s of the last Unicode code point satisfying f(c), or -1 if none do.
func (String) Map ¶
Map returns a copy of the string s with all its characters modified according to the mapping function. If mapping returns a negative value, the character is dropped from the string with no replacement.
func (String) NewReader ¶
NewReader returns a new Reader reading from s. It is similar to bytes.NewBufferString but more efficient and read-only.
func (String) Repeat ¶
Repeat returns a new string consisting of count copies of the string s.
It panics if count is negative or if the result of (len(s) * count) overflows.
func (String) Replace ¶
Replace returns a copy of the string s with the first n non-overlapping instances of old replaced by new.
func (String) Split ¶
Split slices s into all substrings separated by sep and returns a slice of the substrings between those separators. If sep is empty, Split splits after each UTF-8 sequence. It is equivalent to SplitN with a count of -1.
func (String) SplitAfter ¶
SplitAfter slices s into all substrings after each instance of sep and returns a slice of those substrings. If sep is empty, SplitAfter splits after each UTF-8 sequence. It is equivalent to SplitAfterN with a count of -1.
func (String) SplitAfterN ¶
SplitAfterN slices s into substrings after each instance of sep and returns a slice of those substrings. If sep is empty, SplitAfterN splits after each UTF-8 sequence. The count determines the number of substrings to return:
n > 0: at most n substrings; the last substring will be the unsplit remainder. n == 0: the result is nil (zero substrings) n < 0: all substrings
func (String) SplitN ¶
SplitN slices s into substrings separated by sep and returns a slice of the substrings between those separators. If sep is empty, SplitN splits after each UTF-8 sequence. The count determines the number of substrings to return:
n > 0: at most n substrings; the last substring will be the unsplit remainder. n == 0: the result is nil (zero substrings) n < 0: all substrings
func (String) Title ¶
Title returns a copy of the string s with all Unicode letters that begin words mapped to their title case.
BUG(rsc): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
func (String) ToLower ¶
ToLower returns a copy of the string s with all Unicode letters mapped to their lower case.
func (String) ToLowerSpecial ¶
func (s String) ToLowerSpecial(c unicode.SpecialCase) String
ToLowerSpecial returns a copy of the string s with all Unicode letters mapped to their lower case, giving priority to the special casing rules.
func (String) ToTitle ¶
ToTitle returns a copy of the string s with all Unicode letters mapped to their title case.
func (String) ToTitleSpecial ¶
func (s String) ToTitleSpecial(c unicode.SpecialCase) String
ToTitleSpecial returns a copy of the string s with all Unicode letters mapped to their title case, giving priority to the special casing rules.
func (String) ToUpper ¶
ToUpper returns a copy of the string s with all Unicode letters mapped to their upper case.
func (String) ToUpperSpecial ¶
func (s String) ToUpperSpecial(c unicode.SpecialCase) String
ToUpperSpecial returns a copy of the string s with all Unicode letters mapped to their upper case, giving priority to the special casing rules.
func (String) Trim ¶
Trim returns a slice of the string s with all leading and trailing Unicode code points contained in cutset removed.
func (String) TrimLeft ¶
TrimLeft returns a slice of the string s with all leading Unicode code points contained in cutset removed.
func (String) TrimPrefix ¶
TrimPrefix returns s without the provided leading prefix string. If s doesn't start with prefix, s is returned unchanged.
func (String) TrimRight ¶
TrimRight returns a slice of the string s, with all trailing Unicode code points contained in cutset removed.
func (String) TrimSpace ¶
TrimSpace returns a slice of the string s, with all leading and trailing white space removed, as defined by Unicode.
func (String) TrimSuffix ¶
TrimSuffix returns s without the provided trailing suffix string. If s doesn't end with suffix, s is returned unchanged.
type StringBuilder ¶
type StringBuilder struct {
// contains filtered or unexported fields
}
StringBuilder encapsulates the buffer to use for the builder
func (*StringBuilder) Append ¶
func (s *StringBuilder) Append(args ...string) *StringBuilder
Append Appends the given string(s) to the builder
func (*StringBuilder) AppendInt ¶
func (s *StringBuilder) AppendInt(i ...int) *StringBuilder
AppendInt Appends the given number(s) to the builder
func (*StringBuilder) AppendLine ¶
func (s *StringBuilder) AppendLine(lines ...string) *StringBuilder
AppendLine Appends the given string(s) to the builder.
func (*StringBuilder) AppendLinef ¶
func (s *StringBuilder) AppendLinef(format string, args ...interface{}) *StringBuilder
AppendLinef processes a string format based on the format and arguments passed, appends the result to the builder and a new line at the end
func (*StringBuilder) AppendObj ¶
func (s *StringBuilder) AppendObj(objs ...interface{}) *StringBuilder
AppendObj attempts to obtain a string representation of the interface{} (s) and appends it/them to the builder
func (*StringBuilder) AppendRune ¶
func (s *StringBuilder) AppendRune(char rune) *StringBuilder
AppendRune Appends a single character to the builder
func (*StringBuilder) Appendf ¶
func (s *StringBuilder) Appendf(format string, args ...interface{}) *StringBuilder
Appendf processes a string format based on the format and arguments passed and appends the result to the builder
func (*StringBuilder) IsEmpty ¶
func (s *StringBuilder) IsEmpty() bool
IsEmpty Indicates whether the builder is empty
Notes ¶
Bugs ¶
The rule Title uses for word boundaries does not handle Unicode punctuation properly.