Documentation
¶
Index ¶
- type Entry
- type Map
- func (om *Map[K, V]) Entries() []Entry[K, V]
- func (om *Map[K, V]) Get(key K) (V, bool)
- func (om *Map[K, V]) Keys() []K
- func (om *Map[K, V]) MarshalJSON() ([]byte, error)
- func (om *Map[K, V]) MarshalYAML() (any, error)
- func (om *Map[K, V]) Set(key K, val V)
- func (om *Map[K, V]) ToBuiltInMap() map[K]V
- func (om *Map[K, V]) UnmarshalJSON(data []byte) error
- func (om *Map[K, V]) UnmarshalYAML(node ast.Node) error
- type MemFS
- type MemFile
- func (f *MemFile) Close() error
- func (f *MemFile) IsDir() bool
- func (f *MemFile) ModTime() time.Time
- func (f *MemFile) Mode() fs.FileMode
- func (f *MemFile) Name() string
- func (f *MemFile) Read(b []byte) (int, error)
- func (f *MemFile) Size() int64
- func (f *MemFile) Stat() (fs.FileInfo, error)
- func (f *MemFile) Sys() any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
Map is a custom Map impementation that maintains order when adding new items and when unmarshalling from JSON and YAML.
func (*Map[K, V]) Get ¶
Get returns the value associated with a given key in the map. It follows the interface of the built in map type returning true/false in the second parameter to indicate if the key was found in the map.
func (*Map[K, V]) Keys ¶
func (om *Map[K, V]) Keys() []K
Keys returns the keys int the map as a slice.
func (*Map[K, V]) MarshalJSON ¶
func (*Map[K, V]) MarshalYAML ¶
MarshalYAML implements the yaml interface marshaler to preserve insertion order.
It returns a yaml.MapSlice rather than pre-rendered bytes so that the encoder walks the entries through its normal reflection-based encode path. That path threads the current column/indent level through nested values as it recurses. If instead we rendered this map to bytes independently (e.g. via yaml.Marshal) and returned those bytes, the resulting fragment would be parsed back into an AST at column 0 and then spliced into the parent document.
func (*Map[K, V]) Set ¶
func (om *Map[K, V]) Set(key K, val V)
Set adds a new key/value pair and keeps track of the order in which it was added.
func (*Map[K, V]) ToBuiltInMap ¶
func (om *Map[K, V]) ToBuiltInMap() map[K]V
ToBuiltInMap converts the custom ordered map into a built in map type, losing order guarantees
func (*Map[K, V]) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaller interface to enable json.Unarmshal.