Documentation ¶
Index ¶
- func Copy(src []string) (dst []string)
- func SliceOfSlice(slices ...[]string) (sos [][]string)
- func SortReverseStable(s []string)
- func SortStable(s []string)
- func StringKeyPtr(m *map[string]string, targetKey string) (*string, func(), error)
- func TruncateAppendHint(s string, max int, hint string) string
- func TruncatePrependHint(s string, max int, hint string) string
- type Replace
- type ReplaceSet
- type Set
- func (s *Set) Add(el string) bool
- func (s *Set) AddSet(sets ...*Set) *Set
- func (s *Set) AddSlice(slices ...[]string) *Set
- func (s *Set) Clear()
- func (s *Set) Contains(el string) bool
- func (s *Set) Copy() *Set
- func (s *Set) Diff(other *Set) *Set
- func (s *Set) Equals(other *Set) bool
- func (s *Set) Len() int
- func (s *Set) Remove(el string) bool
- func (s *Set) Slice() []string
- func (s *Set) SortedReverseSlice() []string
- func (s *Set) SortedSlice() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SliceOfSlice ¶
func SortReverseStable ¶
func SortReverseStable(s []string)
func SortStable ¶
func SortStable(s []string)
func StringKeyPtr ¶
StringMapPtr returns string pointer which can be used to update a map[string]string value, working around the lack of support for syntax like Fn(&myMap[key]) which leads to the error "cannot take the address of myMap[key]".
The function it returns must be called in order to save each update. An error is returned if the target key is not found in the map.
func TruncateAppendHint ¶
Truncate returns the string with a maximum length enforced and optional appended hint (e.g. "...").
The truncate string and hint will fit inside the maximum length if possible.
Types ¶
type ReplaceSet ¶
ReplaceSet holds replacement definitons indexed by Replace.Old values.
func (*ReplaceSet) Add ¶
func (s *ReplaceSet) Add(old, new string, limit int) *ReplaceSet
Add creates or overwrites a replacement definiton for the given old/target string.
func (*ReplaceSet) InByte ¶
func (s *ReplaceSet) InByte(subject []byte) []byte
InByte returns the subject byte slice with all replacements performed in length-descending order of Replace.Old values.
func (*ReplaceSet) InString ¶
func (s *ReplaceSet) InString(subject string) string
InString returns the subject string with all replacements performed in length-descending order of Replace.Old values.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
func NewSet ¶
func NewSet() *Set
NewSet returns an initialized Set.
It returns a pointer to support use as a map's value type and avoid the "cannot call pointer method" error.