kptoml

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

TOML Parser

TOML parser parses a TOML file to a map[string]interface{} and then traverses the map and adds values into the config store flattening the TOML 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 := kptoml.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 {
	// unmarshal the JSON into  map[string]interface{}
	var d = make(map[string]interface{})
	var _, err = toml.DecodeReader(r, &d)
	if err != nil {
		return err
	}

	kpmap.PopFlatten(d, s)

	return nil
})

Parser parses the given json io.Reader and adds values in dot.path notation into the konfig.Store

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