Documentation
¶
Index ¶
- type Async
- func (a *Async) Has(key string) (has bool)
- func (a *Async) HasAll(keys []string) (has bool)
- func (a *Async) HasOne(keys []string) (has bool)
- func (a *Async) IsMatch(in StringSet) (isMatch bool)
- func (a *Async) Len() int
- func (a *Async) MarshalJSON() (bs []byte, err error)
- func (a *Async) Set(key string)
- func (a *Async) SetAsString(value string) (err error)
- func (a *Async) SetMany(keys []string)
- func (a *Async) Slice() (keys []string)
- func (a *Async) UnmarshalJSON(bs []byte) (err error)
- func (a *Async) Unset(key string)
- func (a *Async) UnsetMany(keys []string)
- 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(in StringSet) (isMatch bool)
- func (m Map) Len() (n int)
- 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
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Async ¶ added in v0.1.8
type Async struct {
// contains filtered or unexported fields
}
Async is a thread-safe wrapper for the stringset.Map
func NewAsyncMap ¶ added in v0.1.8
NewAsyncMap will create a new Map instance of Async
Example ¶
// Initialize new stringset testKeys = NewAsyncMap()
func (*Async) Has ¶ added in v0.1.8
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 (*Async) HasAll ¶ added in v0.1.8
HasAll will return whether or not all the provided keys exist
func (*Async) HasOne ¶ added in v0.1.8
HasOne will return whether or not at least one of the provided keys exist
func (*Async) IsMatch ¶ added in v0.1.8
IsMatch will return whether or not two Asyncs are an identical match
func (*Async) MarshalJSON ¶ added in v0.1.8
MarshalJSON is a JSON encoding helper func
func (*Async) Set ¶ added in v0.1.8
Set will insert a single key
Example ¶
// Set foo key
testKeys.Set("foo")
// Set bar key
testKeys.Set("bar")
func (*Async) SetAsString ¶ added in v0.1.8
SetMany will insert multiple keys
func (*Async) Slice ¶ added in v0.1.8
Slice will return the keys as a slice
Example ¶
keys := testKeys.Slice()
for _, key := range keys {
fmt.Printf("Iterating key: %s\n", key)
}
func (*Async) UnmarshalJSON ¶ added in v0.1.8
UnmarshalJSON is a JSON decoding helper func
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 interface {
Set(key string)
SetMany(keys []string)
Unset(key string)
UnsetMany(keys []string)
Has(key string) (has bool)
HasAll(keys []string) (has bool)
HasOne(keys []string) (has bool)
Slice() (keys []string)
IsMatch(in StringSet) (isMatch bool)
SetAsString(value string) (err error)
Len() (n int)
}