llpath

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 6 Imported by: 59

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InvalidPathString

type InvalidPathString string

InvalidPathString is the error type returned from unparseable paths.

func (InvalidPathString) Error

func (ps InvalidPathString) Error() string

type Path

type Path []PathComponent

Path represents the Path within a nested set of maps.

func MustParsePath

func MustParsePath(in string) Path

MustParsePath is a convenience method for parsing paths that have been previously validated

func ParsePath

func ParsePath(in string) (p Path, err error)

ParsePath parses a Path of form key.[0].otherKey.[1] into a Path object.

func (Path) Concat

func (p Path) Concat(other Path) Path

Concat combines two paths into a new Path without modifying any existing paths.

func (Path) Extend

func (p Path) Extend(pc PathComponent) Path

Extend lengthens the given path with the given component.

func (Path) ExtendMap

func (p Path) ExtendMap(key string) Path

ExtendMap adds a new PathComponent of the pcMapKey type.

func (Path) ExtendSlice

func (p Path) ExtendSlice(index int) Path

ExtendSlice is used to add a new PathComponent of the pcSliceIdx type.

func (Path) GetFrom

func (p Path) GetFrom(source reflect.Value) (result reflect.Value, exists bool)

GetFrom takes a map and fetches the given Path from it.

func (Path) Last

func (p Path) Last() *PathComponent

Last returns a pointer to the Last PathComponent in this Path. If the Path empty, a nil pointer is returned.

func (Path) String

func (p Path) String() string

type PathComponent

type PathComponent struct {
	Type  PathComponentType // One of pcMapKey or pcSliceIdx
	Key   string            // Populated for maps
	Index int               // Populated for slices
}

PathComponent structs represent one breadcrumb in a Path.

func (PathComponent) String

func (pc PathComponent) String() string

type PathComponentType

type PathComponentType int

PathComponentType indicates the type of PathComponent.

func (PathComponentType) String

func (pct PathComponentType) String() string

Jump to

Keyboard shortcuts

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