ds

package
v1.0.0-alpha.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry[K string, V any] struct {
	Key   K
	Value V
}

type Map

type Map[K string, V any] struct {
	// contains filtered or unexported fields
}

Map is a custom Map impementation that maintains order when adding new items and when unmarshalling from JSON and YAML.

func NewMap

func NewMap[K string, V any]() *Map[K, V]

NewMap creates a new ordered Map.

func (*Map[K, V]) Entries

func (om *Map[K, V]) Entries() []Entry[K, V]

func (*Map[K, V]) Get

func (om *Map[K, V]) Get(key K) (V, bool)

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 (om *Map[K, V]) MarshalJSON() ([]byte, error)

func (*Map[K, V]) MarshalYAML

func (om *Map[K, V]) MarshalYAML() ([]byte, error)

MarshalYAML implements the yaml node marshaler to preserve insertion order.

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

func (om *Map[K, V]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaller interface to enable json.Unarmshal.

func (*Map[K, V]) UnmarshalYAML

func (om *Map[K, V]) UnmarshalYAML(node ast.Node) error

UnmarshalYAML implements the yaml.Unmarshaller interface to enable yaml.Unarmshal.

type MemFS

type MemFS map[string][]byte

MemFS satisfies the fs.FS interface

func (MemFS) Open

func (m MemFS) Open(name string) (fs.File, error)

func (MemFS) Persist

func (m MemFS) Persist(targetDir string) error

Persist writes all in-memory files safely to the specified target directory on disk.

type MemFile

type MemFile struct {
	// contains filtered or unexported fields
}

MemFile satisfies the fs.File interface

func (*MemFile) Close

func (f *MemFile) Close() error

func (*MemFile) IsDir

func (f *MemFile) IsDir() bool

func (*MemFile) ModTime

func (f *MemFile) ModTime() time.Time

func (*MemFile) Mode

func (f *MemFile) Mode() fs.FileMode

func (*MemFile) Name

func (f *MemFile) Name() string

Dummy methods below satisfy the fs.FileInfo metadata interface

func (*MemFile) Read

func (f *MemFile) Read(b []byte) (int, error)

func (*MemFile) Size

func (f *MemFile) Size() int64

func (*MemFile) Stat

func (f *MemFile) Stat() (fs.FileInfo, error)

func (*MemFile) Sys

func (f *MemFile) Sys() any

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL