sources

package
v0.0.0-...-c9dc3a1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2017 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug = false

Debug controls sources debug output

View Source
var (
	// ErrKeyExists should be returned when the key has already
	// been registered with the source and it can't be re-registered
	// e.g. when using CommandLine, which uses the flag package
	ErrKeyExists = errors.New("Key already exists")
)
View Source
var Logger func(message string, args ...interface{})

Logger is called for each log message. If nil, log.Printf will be called instead.

Functions

This section is empty.

Types

type CommandLine

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

CommandLine implements command line configuration using the flag package

func (*CommandLine) Cleanup

func (cl *CommandLine) Cleanup()

Cleanup is called at the end of parsing

func (*CommandLine) Get

func (cl *CommandLine) Get(key string, overrideDefault *string) (string, error)

Get is called to retrieve a key value

func (*CommandLine) GetArray

func (cl *CommandLine) GetArray(key string, overrideDefault *[]string) ([]string, error)

func (*CommandLine) Init

func (cl *CommandLine) Init(args map[string]string) error

Init is called at the start of a new struct

func (*CommandLine) Register

func (cl *CommandLine) Register(key, defaultValue string, params map[string]string, t reflect.Type) error

Register is called to register each struct field

type Environment

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

Environment implements environment variable configuration using envconf

func (*Environment) Cleanup

func (env *Environment) Cleanup()

Cleanup is called at the end of parsing

func (*Environment) Get

func (env *Environment) Get(key string, overrideDefault *string) (string, error)

Get is called to retrieve a key value

func (*Environment) GetArray

func (env *Environment) GetArray(key string, overrideDefault *[]string) ([]string, error)

GetArray is called to retrieve an array value

func (*Environment) Init

func (env *Environment) Init(args map[string]string) error

Init is called at the start of a new struct

func (*Environment) Register

func (env *Environment) Register(key, defaultValue string, params map[string]string, t reflect.Type) error

Register is called to register each struct field

type Source

type Source interface {
	// Init is called at the start of a new struct
	Init(args map[string]string) error
	// Cleanup is called at the end of parsing
	Cleanup()
	// Register is called to register each struct field
	Register(key, defaultValue string, params map[string]string, t reflect.Type) error
	// Get is called to retrieve a key value
	// - FIXME could use interface{} and maintain types, e.g. json?
	Get(key string, overrideDefault *string) (string, error)
	// GetArray is called to retrieve an array value
	GetArray(key string, overrideDefault *[]string) ([]string, error)
}

Source should be implemented by Gofigure sources, e.g. environment, command line, file, http etc

Jump to

Keyboard shortcuts

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