forked from Archives/fx
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
456 B
Go
27 lines
456 B
Go
2 years ago
|
package dict
|
||
|
|
||
|
type Dict struct {
|
||
|
Keys []string
|
||
|
Values map[string]interface{}
|
||
|
}
|
||
|
|
||
|
func NewDict() *Dict {
|
||
|
return &Dict{
|
||
|
Keys: make([]string, 0),
|
||
|
Values: make(map[string]interface{}),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (d *Dict) Get(key string) (interface{}, bool) {
|
||
|
val, exists := d.Values[key]
|
||
|
return val, exists
|
||
|
}
|
||
|
|
||
|
func (d *Dict) Set(key string, value interface{}) {
|
||
|
_, exists := d.Values[key]
|
||
|
if !exists {
|
||
|
d.Keys = append(d.Keys, key)
|
||
|
}
|
||
|
d.Values[key] = value
|
||
|
}
|