xyaml

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 3 Imported by: 7

README

eXtend YAML

Tests GoDoc Go Report Card

Get it on Codeberg

is a library to extend gopkg.in/yaml.v3 to allow merging sequences

Features

  • merge sequences
    • single alias
    • array of alias

How to use

go get codeberg.org/6543/xyaml

and just replace your

err := yaml.Unmarshal(in, out)

with

err := xyaml.Unmarshal(in, out)

Examples

merge sequences
array1: &my_array_alias
- foo
- bar

array2:
- <<: *my_array_alias
- NEW1
- <<: [*my_array_alias, *my_array_alias]

will be interpreted as:

array1:
- foo
- bar

array2:
- foo
- bar
- NEW1
- foo
- bar
- foo
- bar

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMaxDepth indicates there is likely a loop that got caught
	ErrMaxDepth = errors.New("max depth reached")
	// ErrBrokenMappingNode indicates a broken map node
	ErrBrokenMappingNode = errors.New("broken mapping node")
	// ErrSequenceMerge show that there is a sequence merge
	// indicated but got wrong values to work with
	ErrSequenceMerge = errors.New("sequence merge failed")
)

Functions

func Marshal

func Marshal(in interface{}) (out []byte, err error)

Marshal just use the normal underlying yaml.v3 lib func

func MergeSequences added in v1.1.0

func MergeSequences(node *yaml.Node) error

MergeSequences recursively search for sequence merge indicator "<<:" and merge if detected

func Unmarshal

func Unmarshal(in []byte, out interface{}) (err error)

Unmarshal use underlying yaml.v3 lib func to decode and alter based on the extensions afterwards

Types

This section is empty.

Jump to

Keyboard shortcuts

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