yamlutils

package module
v0.0.0-...-d95211f Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MPL-2.0 Imports: 10 Imported by: 2

Documentation

Overview

Package yamlutils - Utilities to read yml files like if using xpath

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidChildTypeKeyValue = fmt.Errorf("invalid child type, must be 'key: value'")

ErrInvalidChildTypeKeyValue - The child type is invalid.

View Source
var ErrInvalidParentType = fmt.Errorf("invalid parent type, must be list or key/value")

ErrInvalidParentType - The parent type is invalid.

View Source
var Logger = log.New(ioutil.Discard, "yamlutils ", log.LstdFlags)

Logger - Custom lib logger

Functions

func AddChild

func AddChild(m *interface{}, child string) error

func AddChildToTree

func AddChildToTree(parent *interface{}, current *interface{}, p []string, child string) error

Types

type YML

type YML struct {
	Tree interface{}
}

YML object

func NewFromFile

func NewFromFile(filename string) ([]*YML, error)

NewFromFile returns a list of pointers to a YML object from a file.

Returns a list since YAML files can contain multiple documents: https://yaml.org/spec/1.2-old/spec.html#id2800401

func NewFromReader

func NewFromReader(reader io.Reader) ([]*YML, error)

NewFromReader returns a list of pointers to a YML object from an io.Reader.

Returns a list since YAML files can contain multiple documents: https://yaml.org/spec/1.2-old/spec.html#id2800401

func NewFromString

func NewFromString(str string) (*YML, error)

NewFromString - returns a pointer to a YML object from a string.

func (*YML) AddString

func (y *YML) AddString(keys []string, input string) (string, error)

func (*YML) GetString

func (y *YML) GetString(include bool, keys []string) (string, error)

GetString returns a string designated by path. Path is a string with elements separated by /. Array indexes are given as a number. For example: "level1/level2/3/level4"

Jump to

Keyboard shortcuts

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