omap

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 6 Imported by: 0

README

ci go report card

gordered-map

A simple wrapper to provide an ordered golang type to have fixed order map.

This package doesn't pretend to be performent nor is the usage convinient, but it helps me in use-cases where I have to read a JSON file to a generic dictionary, manipulate the content and want to have after serialization the initial order of the input. In other words in tries to tackle the fact that golang maps only have a random order when you travers them ... no I don't complain X-D

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAnyTypedChildArray

func GetAnyTypedChildArray(m *MapThing, key string) ([]any, bool)

func GetArrayLen

func GetArrayLen(a ordered.OrderedArray) int

func GetChildArray

func GetChildArray(m *MapThing, key string) (ordered.OrderedArray, bool)

func GetTypedChildArray

func GetTypedChildArray[T any](m *MapThing, key string) ([]T, bool)

func GetValue

func GetValue[T any](m *MapThing, key string) (T, bool)

func GetValueAt

func GetValueAt[T any](a ordered.OrderedArray, index int) (T, error)

func HasValue

func HasValue(m *MapThing, key string) bool

func IterateOverArray

func IterateOverArray[T any](array any, castFunc CastFunc2[T]) iter.Seq2[int, T]

func NewOrderedValue added in v0.2.0

func NewOrderedValue[T any](value T) (ordered.OrderedValue, error)

func OrderedPair2Value

func OrderedPair2Value(value ordered.OrderedPair) (any, bool)

func OrderedValue2Value

func OrderedValue2Value[T any](value ordered.OrderedValue) (T, bool)

func Remove added in v0.2.0

func Remove(m *MapThing, key string)

func Set

func Set[T any](m *MapThing, key string, value T) error

func ToText

func ToText(v any) string

Types

type CastFunc

type CastFunc func(value ordered.OrderedPair) (any, bool)

type CastFunc2

type CastFunc2[T any] func(value ordered.OrderedValue) (T, bool)

type MapThing

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

func GetChildMap

func GetChildMap(m *MapThing, key string) (*MapThing, bool)

func NewFromJSON

func NewFromJSON(data []byte) (*MapThing, error)

func NewFromJSONFile

func NewFromJSONFile(fileName string) (*MapThing, error)

func NewMapThing added in v0.2.0

func NewMapThing() MapThing

func (*MapThing) Iterate

func (m *MapThing) Iterate() iter.Seq2[string, any]

func (*MapThing) IterateOverMaps

func (m *MapThing) IterateOverMaps() iter.Seq2[string, MapThing]

helps to interate over sub dictionaries

func (*MapThing) IterateToValue

func (m *MapThing) IterateToValue(castFunc CastFunc) iter.Seq2[string, any]

func (*MapThing) Len added in v0.2.0

func (m *MapThing) Len() (int, error)

func (*MapThing) Serialize

func (m *MapThing) Serialize() ([]byte, error)

func (*MapThing) SerializeJSONFile

func (m *MapThing) SerializeJSONFile(fileName string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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