gofigure: github.com/ian-kent/gofigure/sources Index | Files

package sources

import "github.com/ian-kent/gofigure/sources"

Index

Package Files

commandline.go environment.go sources.go

Variables

var Debug = false

Debug controls sources debug output

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")
)
var Logger func(message string, args ...interface{})

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

type CommandLine Uses

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

CommandLine implements command line configuration using the flag package

func (*CommandLine) Cleanup Uses

func (cl *CommandLine) Cleanup()

Cleanup is called at the end of parsing

func (*CommandLine) Get Uses

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

Get is called to retrieve a key value

func (*CommandLine) GetArray Uses

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

func (*CommandLine) Init Uses

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

Init is called at the start of a new struct

func (*CommandLine) Register Uses

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 Uses

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

Environment implements environment variable configuration using envconf

func (*Environment) Cleanup Uses

func (env *Environment) Cleanup()

Cleanup is called at the end of parsing

func (*Environment) Get Uses

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

Get is called to retrieve a key value

func (*Environment) GetArray Uses

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

GetArray is called to retrieve an array value

func (*Environment) Init Uses

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

Init is called at the start of a new struct

func (*Environment) Register Uses

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 Uses

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

Package sources imports 8 packages (graph) and is imported by 2 packages. Updated 2017-05-12. Refresh now. Tools for package owners.