source

package
v0.0.0-...-77f7900 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrValueNotMap = errors.New("map expected as value for namespace element")
)

Known errors

Functions

This section is empty.

Types

type Environment

type Environment struct{}

Environment provides a configuration source from the environment variables

func (Environment) Value

func (e Environment) Value(ns []string, k string) interface{}

Value returns value of the environment variable which matches the key, if any. If not found, a second try is made using an upper-case version, substituting underscores for hypens.

type Flag

type Flag struct{}

Flag provides a configuration source from the command-line flags

func (Flag) Value

func (f Flag) Value(ns []string, k string) interface{}

Value returns value of the flag which matches the key, if any. If not found, a second try is made using a lower-case version, substituting hypens for underscores

type Map

type Map map[string]interface{}

Map defines a source based on a standard map of interfaces with a string key.

func NewJSON

func NewJSON(r io.Reader) (m Map, err error)

NewJSON returns a new map source based on the JSON data stored in the reader.

func NewJSONFromFile

func NewJSONFromFile(filename string) (m Map, err error)

NewJSONFromFile is a convenience function that creates a new JSON source from the file specified by filename.

func (Map) SetValue

func (m Map) SetValue(ns []string, k string, x interface{}) (err error)

SetValue adds or replaces a value identified by the namespace and key

func (Map) Value

func (m Map) Value(ns []string, k string) interface{}

Value returns the value from the map source representd by the namespace and key; otherwise, returns nil.

type Multi

type Multi []config.Source

Multi source combines multiple sources into one

func (Multi) Value

func (m Multi) Value(ns []string, k string) interface{}

Value returns the first non-nil, if any, value from the composite sources.

Jump to

Keyboard shortcuts

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