Documentation
¶
Index ¶
- type Map
- func (m Map) Has(key string) (has bool)
- func (m Map) HasAll(keys []string) (has bool)
- func (m Map) HasOne(keys []string) (has bool)
- func (m Map) IsMatch(a Map) (isMatch bool)
- func (m Map) MarshalJSON() (bs []byte, err error)
- func (m *Map) Set(key string)
- func (m *Map) SetAsString(value string) (err error)
- func (m Map) SetMany(keys []string)
- func (m Map) Slice() (keys []string)
- func (m *Map) UnmarshalJSON(bs []byte) (err error)
- func (m Map) Unset(key string)
- func (m Map) UnsetMany(keys []string)
- type StringSet
- func (s *StringSet) Has(key string) (has bool)
- func (s *StringSet) HasAll(keys ...string) (has bool)
- func (s *StringSet) HasOne(keys ...string) (has bool)
- func (s *StringSet) IsMatch(a *StringSet) (isMatch bool)
- func (s *StringSet) Len() int
- func (s *StringSet) MarshalJSON() (bs []byte, err error)
- func (s *StringSet) Set(key string)
- func (s *StringSet) SetMany(keys ...string)
- func (s *StringSet) Slice() (keys []string)
- func (s *StringSet) UnmarshalJSON(bs []byte) (err error)
- func (s *StringSet) Unset(key string)
- func (s *StringSet) UnsetMany(keys ...string)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map map[string]struct{}
Map is the lower-level underlying type for storing a string set Note: This is not thread-safe. If you need thread-safety, please use StringSet type
func (Map) IsMatch ¶ added in v0.1.5
IsMatch will return whether or not two Maps are an identical match
func (Map) MarshalJSON ¶
MarshalJSON is a JSON encoding helper func
func (*Map) SetAsString ¶ added in v0.1.7
SetAsString will set a map from a comma separated string value Note: This allows stringset to match the reflectio.Setter interface
func (*Map) UnmarshalJSON ¶
UnmarshalJSON is a JSON decoding helper func
type StringSet ¶
type StringSet struct {
// contains filtered or unexported fields
}
StringSet is a thread-safe wrapper for the stringset.Map
func New ¶
New will create a new instance of StringSet
Example ¶
// Initialize new stringset testKeys = New()
func (*StringSet) Has ¶
Has will return whether or not a key exists
Example ¶
if testKeys.Has("foo") {
fmt.Println("We have foo!")
}
if !testKeys.Has("bar") {
fmt.Println("We do not have bar!")
}
func (*StringSet) HasOne ¶
HasOne will return whether or not at least one of the provided keys exist
func (*StringSet) IsMatch ¶ added in v0.1.5
IsMatch will return whether or not two StringSets are an identical match
func (*StringSet) MarshalJSON ¶
MarshalJSON is a JSON encoding helper func
func (*StringSet) Set ¶
Set will insert a single key
Example ¶
// Set foo key
testKeys.Set("foo")
// Set bar key
testKeys.Set("bar")
func (*StringSet) Slice ¶
Slice will return the keys as a slice
Example ¶
keys := testKeys.Slice()
for _, key := range keys {
fmt.Printf("Iterating key: %s\n", key)
}
func (*StringSet) UnmarshalJSON ¶
UnmarshalJSON is a JSON decoding helper func