config

package module
v0.0.0-...-c737911 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2019 License: MIT Imports: 12 Imported by: 0

README

Config

[WIP]

A library for consistently applying configuration to Go programs from files, environment variables and command line flags.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSourceImplementation = errors.New("reader implementation")
	ErrNoConfig             = errors.New("empty config")
	ErrInvalidTarget        = errors.New("invalid target")
	ErrInvalidInputValue    = errors.New("invalid input value")
	ErrTooManyValues        = errors.New("too many values")
	ErrNumericOverflow      = fmt.Errorf("%w: integer overflow", ErrInvalidInputValue)
	ErrConflictingKeys      = errors.New("conflicting keys")
)

Functions

func Apply

func Apply(applyTo interface{}, s Source) error

It may change the target even if fails.

Types

type Node

type Node interface {
	Type() NodeType
	Primitive() interface{}
	Len() int
	Item(int) Node
	Keys() []string
	Field(string) Node
}

type NodeType

type NodeType int
const (
	Nil NodeType = 1 << iota
	Bool
	Int
	Float
	String
	List
	Structure

	Number    = Int | Float
	Primitive = Bool | Number | String
)

type Reader

type Reader interface {
	Read() (interface{}, error)
	TypeMapping() map[NodeType]NodeType
}

type Source

type Source interface {
	Read() (Node, error)
}

func INI

func INI(r io.Reader) Source

func JSON

func JSON(r io.Reader) Source

func Merge

func Merge(s ...Source) Source

func Override

func Override(s ...Source) Source

func WithReader

func WithReader(l Reader) Source

func YAML

func YAML(r io.Reader) Source

Directories

Path Synopsis
ini
test

Jump to

Keyboard shortcuts

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