patch

package
v1.0.69 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	OpAdd     = Op("add")
	OpRemove  = Op("remove")
	OpReplace = Op("replace")
	OpMove    = Op("move")
	OpCopy    = Op("copy")
	OpTest    = Op("test")
)

Variables

View Source
var (
	ErrNoOo           = errors.New("operations object is nil")
	ErrNoTarget       = errors.New("target is nil")
	ErrOoPathMissing  = errors.New("'path' field is missing in operations object")
	ErrOoValueMissing = errors.New("'value' field is missing in operations object")
	ErrOoFromMissing  = errors.New("'from' field is missing in operations object")
)

Functions

func Do

func Do(obj *OpObj, target dom.ContainerBuilder) error

Do perform patch operation against designated target. Object is modified in place, or error is returned.

func NewPathParser added in v1.0.66

func NewPathParser() path.Parser

func NewPathSerializer added in v1.0.66

func NewPathSerializer() path.Serializer

Types

type Op

type Op string

type OpObj

type OpObj struct {
	Op    Op
	From  *Path    // copy,move
	Path  Path     // test,copy,move,replace,remove,add
	Value dom.Node // test,replace,add
}

OpObj is operation object containing all necessary data to perform patch operation

type Path

type Path []PathSegment

func MustParsePath

func MustParsePath(pathSpec string) Path

func ParsePath

func ParsePath(pathSpec string) (Path, error)

func (Path) Eval

func (p Path) Eval(target dom.Container) (dom.NodeList, dom.Node)

Eval evaluates path within provided target dom.Container. Call to this function returns pair, where one part is series of Nodes encountered while walking from root of target dom.Container down the path, second part is final Node. If path does not fully resolve, second part will be nil, while first part will contain all Nodes up to point where resolution stopped.

func (Path) LastSegment

func (p Path) LastSegment() PathSegment

func (Path) Parent

func (p Path) Parent() Path

func (Path) String

func (p Path) String() string

String returns lexical representation of this path according to RFC

type PathSegment

type PathSegment string

func (PathSegment) IsNumeric

func (ps PathSegment) IsNumeric() (int, bool)

TODO add support for "-" - the "last" item designation

Jump to

Keyboard shortcuts

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