orderedmap

package
v0.0.0-...-4845449 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package orderedmap is modified version of: https://github.com/iancoleman/orderedmap

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByPair

type ByPair struct {
	Pairs    []*Pair
	LessFunc func(a *Pair, j *Pair) bool
}

func (ByPair) Len

func (a ByPair) Len() int

func (ByPair) Less

func (a ByPair) Less(i, j int) bool

func (ByPair) Swap

func (a ByPair) Swap(i, j int)

type Key

type Key []Step

KeyPath - path to a value in the OrderedMap (JSON file).

func KeyFromStr

func KeyFromStr(str string) Key

func (Key) First

func (v Key) First() Step

func (Key) Last

func (v Key) Last() Step

func (Key) String

func (v Key) String() string

func (Key) WithoutFirst

func (v Key) WithoutFirst() Key

func (Key) WithoutLast

func (v Key) WithoutLast() Key

type MapStep

type MapStep string

func (MapStep) Key

func (v MapStep) Key() string

func (MapStep) String

func (v MapStep) String() string

type OrderedMap

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

func FromPairs

func FromPairs(pairs []Pair) *OrderedMap

func New

func New() *OrderedMap

func (*OrderedMap) Clone

func (o *OrderedMap) Clone() *OrderedMap

func (*OrderedMap) DeepCopy

func (o *OrderedMap) DeepCopy(callback deepcopy.TranslateFunc, steps deepcopy.Steps, visited deepcopy.VisitedMap) *OrderedMap

func (*OrderedMap) Delete

func (o *OrderedMap) Delete(key string)

func (*OrderedMap) Get

func (o *OrderedMap) Get(key string) (interface{}, bool)

func (*OrderedMap) GetNested

func (o *OrderedMap) GetNested(keysStr string) (value interface{}, found bool, err error)

func (*OrderedMap) GetNestedMap

func (o *OrderedMap) GetNestedMap(keysStr string) (m *OrderedMap, found bool, err error)

func (*OrderedMap) GetNestedOrNil

func (o *OrderedMap) GetNestedOrNil(keysStr string) interface{}

GetNestedOrNil returns nil if values is not found or an error occurred.

func (*OrderedMap) GetNestedPath

func (o *OrderedMap) GetNestedPath(keys Key) (value interface{}, found bool, err error)

func (*OrderedMap) GetNestedPathMap

func (o *OrderedMap) GetNestedPathMap(keys Key) (m *OrderedMap, found bool, err error)

func (*OrderedMap) GetNestedPathOrNil

func (o *OrderedMap) GetNestedPathOrNil(keys Key) interface{}

GetNestedPathOrNil returns nil if values is not found or an error occurred.

func (*OrderedMap) GetOrNil

func (o *OrderedMap) GetOrNil(key string) interface{}

func (*OrderedMap) Keys

func (o *OrderedMap) Keys() []string

func (*OrderedMap) Len

func (o *OrderedMap) Len() int

func (OrderedMap) MarshalJSON

func (o OrderedMap) MarshalJSON() ([]byte, error)

func (*OrderedMap) Set

func (o *OrderedMap) Set(key string, value interface{})

func (*OrderedMap) SetNested

func (o *OrderedMap) SetNested(keysStr string, value interface{}) error

SetNested value defined by key, eg. "parameters.foo[123]".

func (*OrderedMap) SetNestedPath

func (o *OrderedMap) SetNestedPath(keys Key, value interface{}) error

SetNestedPath value defined by key, eg. Key{MapStep("parameters), MapStep("foo"), SliceStep(123)}.

func (*OrderedMap) Sort

func (o *OrderedMap) Sort(lessFunc func(a *Pair, b *Pair) bool)

Sort Sort the map using your sort func.

func (*OrderedMap) SortKeys

func (o *OrderedMap) SortKeys(sortFunc func(keys []string))

SortKeys Sort the map keys using your sort func.

func (*OrderedMap) ToMap

func (o *OrderedMap) ToMap() map[string]interface{}

func (*OrderedMap) UnmarshalJSON

func (o *OrderedMap) UnmarshalJSON(b []byte) error

func (*OrderedMap) VisitAllRecursive

func (o *OrderedMap) VisitAllRecursive(callback visitCallback)

VisitAllRecursive calls callback for each nested key in OrderedMap or []interface{}.

type Pair

type Pair struct {
	Key   string
	Value interface{}
}

type SliceStep

type SliceStep int

func (SliceStep) Index

func (v SliceStep) Index() int

func (SliceStep) String

func (v SliceStep) String() string

type Step

type Step interface {
	String() string
}

Jump to

Keyboard shortcuts

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