yaml

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 5 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() 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.CaseInsensitive(),
	query.CustomExtractFunc(yamlextractor.MapSliceExtractFunc()),
).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