fx/dict.go

27 lines
456 B
Go
Raw Normal View History

2022-03-11 15:15:24 +00:00
package main
type dict struct {
2022-04-02 20:59:36 +00:00
keys []string
values map[string]interface{}
2022-03-11 15:15:24 +00:00
}
func newDict() *dict {
2022-03-29 16:13:41 +00:00
return &dict{
2022-04-02 20:59:36 +00:00
keys: make([]string, 0),
values: make(map[string]interface{}),
2022-03-29 16:13:41 +00:00
}
2022-03-11 15:15:24 +00:00
}
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
}