kpkeyval

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: 6 Imported by: 0

README

KV Parser

KV parser is a key value parser to parse an io.Reader's content of key/values with a configurable separator and add it into a konfig.Store.

Ex:

bar=foo
foo=bar

Will add the following key/value to the config

"foo" => "bar"
"bar" => "foo"

Usage

func main() {
	var v = konfig.Values{}
	var p = kpkeyval.New(&kpkeyval.Config{})

	p.Parse(strings.NewReader(
		"bar=foo\nfoo=bar",
	), v)

	fmt.Println(v) // map[bar:foo foo:bar]
}

Documentation

Overview

Package kpkeyval provides a key value parser to parse an io.Reader's content of key/values with a configurable separator and add it into a konfig.Store.

Index

Constants

View Source
const DefaultSep = "="

DefaultSep is the default key value separator

Variables

View Source
var (
	ErrInvalidConfigFileFormat = errors.New("Err invalid file format")
)

ErrInvalidConfigFileFormat is the error returned when a problem is encountered when parsing the config file

Functions

This section is empty.

Types

type Config

type Config struct {
	// Sep is the separator between keys and values
	Sep string
}

Config is the configuration of the key value parser

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser implements fileloader.Parser It parses a file of key/values with a specific separator and stores in the konfig.Store

func New

func New(cfg *Config) *Parser

New creates a new parser with the given config

func (*Parser) Parse

func (k *Parser) Parse(r io.Reader, cfg konfig.Values) error

Parse implement the fileloader.Parser interface

Jump to

Keyboard shortcuts

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