yaml

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 4 Imported by: 3

Documentation

Overview

Package yaml provides a function to extract values from yaml.MapSlice.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapSliceExtractFunc

func MapSliceExtractFunc(caseInsensitive bool) func(query.ExtractFunc) query.ExtractFunc

MapSliceExtractFunc is a function for query.CustomExtractFunc option to extract values from yaml.MapSlice.

Example
b := []byte(`- foo: bar`)
var v interface{}
if err := yaml.UnmarshalWithOptions(b, &v, yaml.UseOrderedMap()); err != nil {
	log.Fatal(err)
}

q := query.New(
	query.CustomExtractFunc(yamlextractor.MapSliceExtractFunc(true)),
).Index(0).Key("FOO")
got, err := q.Extract(v)
if err != nil {
	log.Fatal(err)
}
fmt.Println(got)
Output:

bar

Types

This section is empty.

Jump to

Keyboard shortcuts

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