kpyaml

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 5 Imported by: 0

README

YAML Parser

YAML parser parses a YAML file to a map[string]interface{} and then traverses the map and adds values into the config store flattening the YAML using dot notation for keys.

Ex:

foo: "bar"
nested: 
    firstName: "john"
    lastName: "doe"
    list: 
    - 1
    - 2

Will add the following key/value to the config

"foo" => "bar"
"nested.firstName" => "john"
"nested.lastName" => "doe"
"nested.list" => []int{1,2}

Usage

err := kpyaml.Parser.Parse(strings.NewReader(`foo: "bar"`), konfig.Values{})

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Parser = parser.Func(func(r io.Reader, s konfig.Values) error {
	var dec = yaml.NewDecoder(r)

	var d = make(map[string]interface{})
	var err = dec.Decode(&d)
	if err != nil {
		return err
	}

	kpmap.PopFlatten(d, s)

	return nil
})

Parser is the YAML Parser it implements parser.Parser

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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