Documentation
¶
Overview ¶
Package bag implements some utility methods on top of a generic map in order to minimize the number of written type assertions in your project.
Index ¶
- type Bag
- func (b *Bag) Get(key string) (value interface{})
- func (b *Bag) GetBool(key string) bool
- func (b *Bag) GetByteSlice(key string) (value []byte)
- func (b *Bag) GetInt(key string) int
- func (b *Bag) GetMapStringString(key string) map[string]string
- func (b *Bag) GetString(key string) string
- func (b *Bag) Has(key string) bool
- func (b *Bag) Map() map[string]interface{}
- func (b *Bag) Set(key string, value interface{})
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bag ¶
type Bag struct {
// contains filtered or unexported fields
}
A Bag uses a map[string]interface{} to hold data. It is safe for concurrent use.
func NewBag ¶
func NewBag() *Bag
Instantiates a Bag
Example ¶
bag := NewBag()
bag.Set("foo", "hey, this is a string and here is a number:")
bag.Set("bar", 42)
fmt.Println(bag.GetString("foo"), bag.GetInt("bar"))
Output: hey, this is a string and here is a number: 42
func (*Bag) GetByteSlice ¶
Click to show internal directories.
Click to hide internal directories.
