Documentation ¶
Index ¶
- type FeatureMap
- func (fm *FeatureMap) Delete(key string) (value interface{}, ok bool)
- func (fm *FeatureMap) EntriesIter() func() (*KVPair, bool)
- func (fm *FeatureMap) EntriesReverseIter() func() (*KVPair, bool)
- func (fm *FeatureMap) Get(key string) interface{}
- func (fm *FeatureMap) GetValue(key string) (value interface{}, ok bool)
- func (fm *FeatureMap) Has(key string) bool
- func (fm *FeatureMap) Keys() []string
- func (fm *FeatureMap) Len() int
- func (fm *FeatureMap) MarshalJSON() ([]byte, error)
- func (fm *FeatureMap) Set(key string, value interface{})
- func (fm *FeatureMap) UnmarshalJSON(data []byte) error
- func (fm *FeatureMap) Values() []interface{}
- type KVPair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FeatureMap ¶
type FeatureMap struct {
// contains filtered or unexported fields
}
FeatureMap has similar operations as the default map, but maintains the order of inserted keys. Similar to map, all single key operations e.g. get, set and delete runs at O(1). Although the JSON spec says the keys order of an object should not matter, sometimes the order of JSON objects and their keys matters when printing them for humans. Therefore we have to maintain the object keys in the same order as they come in.
Disclaimer, same as Go's default map, FeatureMap is not safe for concurrent use. If you need atomic access, may use a sync.Mutex to synchronize.
More references may be found below.
Go maps in action https://blog.golang.org/go-maps-in-action JSON and Go https://blog.golang.org/json-and-go Go-Ordered-JSON https://github.com/virtuald/go-ordered-json Python OrderedDict https://github.com/python/cpython/blob/2.7/Lib/collections.py#L38 port OrderedDict https://github.com/cevaris/ordered_map original proposal https://gitlab.com/c0b/go-ordered-json/-/blob/49bbdab258c2e707b671515c36308ea48134970d/ordered.go
func New ¶
func New() *FeatureMap
func (*FeatureMap) Delete ¶
func (fm *FeatureMap) Delete(key string) (value interface{}, ok bool)
func (*FeatureMap) EntriesIter ¶
func (fm *FeatureMap) EntriesIter() func() (*KVPair, bool)
func (*FeatureMap) EntriesReverseIter ¶
func (fm *FeatureMap) EntriesReverseIter() func() (*KVPair, bool)
func (*FeatureMap) Get ¶
func (fm *FeatureMap) Get(key string) interface{}
func (*FeatureMap) GetValue ¶
func (fm *FeatureMap) GetValue(key string) (value interface{}, ok bool)
func (*FeatureMap) Has ¶
func (fm *FeatureMap) Has(key string) bool
func (*FeatureMap) Keys ¶
func (fm *FeatureMap) Keys() []string
func (*FeatureMap) Len ¶
func (fm *FeatureMap) Len() int
func (*FeatureMap) MarshalJSON ¶
func (fm *FeatureMap) MarshalJSON() ([]byte, error)
func (*FeatureMap) Set ¶
func (fm *FeatureMap) Set(key string, value interface{})
func (*FeatureMap) UnmarshalJSON ¶
func (fm *FeatureMap) UnmarshalJSON(data []byte) error
func (*FeatureMap) Values ¶
func (fm *FeatureMap) Values() []interface{}
Click to show internal directories.
Click to hide internal directories.