Documentation
¶
Index ¶
- func Filter(s []string, p Predicate) []string
- func MapToSlice(m map[string]struct{}) []string
- func Ptr(v string) *string
- func PtrDefToNil(v string, def string) *string
- func PtrEmptyToNil(v string) *string
- func SafeIndex(s []string, i int) string
- func SafeIndexPtr(s []string, i int) *string
- func SkipDuplicates(c *Collector)
- func SkipEmpties(c *Collector)
- func SliceToMap(s []string) map[string]struct{}
- func SwapMap(m map[string]string) (map[string]string, error)
- func Val(v *string) string
- func ValDef(v *string, def string) string
- type Collector
- type CollectorOption
- type Predicate
- type Slice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
Filter returns a shallow copy of the slice containing only the elements for which the predicate is true.
func MapToSlice ¶
MapToSlice converts a map to slice.
func PtrDefToNil ¶
PtrDefToNil returns a pointer to the value, or nil if "def".
func PtrEmptyToNil ¶
PtrEmptyToNil returns a pointer to the value, or nil if "".
func SafeIndexPtr ¶
SafeIndexPtr returns "s[i]" if possible, an nil otherwise.
func SkipDuplicates ¶
func SkipDuplicates(c *Collector)
SkipDuplicates skips adding duplicate strings.
func SliceToMap ¶
SliceToMap converts a slice to map.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector collects strings. It must be initialized using NewCollector, and its behavior can be regulated via options.
func NewCollector ¶
func NewCollector(options ...CollectorOption) *Collector
NewCollector initializes a new collector.
type CollectorOption ¶
type CollectorOption func(*Collector)
CollectorOption configures a Collector.
func InitialCap ¶
func InitialCap(cap int) CollectorOption
InitialCap sets the initial capacity of the underlying data structures.
type Predicate ¶
Predicate describes a predicate.