nest

package module
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2018 License: MIT Imports: 16 Imported by: 3

README

Nest

Build Status Go Report Card GoDoc

Nest is a convenience wrapper around Viper providing a way to map configuration values to a struct and it's fields by using annotations.

License

The MIT License (MIT). Please see License File for more information.

Documentation

Overview

Package nest is a convenience wrapper around Viper providing a way to map configuration values to a struct and it's fields by using annotations.

Index

Constants

View Source
const (
	TagIgnored    = "ignored"
	TagDefault    = "default"
	TagRequired   = "required"
	TagSplitWords = "split_words"

	TagPrefix = "prefix"

	TagEnvironment = "env"

	TagFlag = "flag"

	TagUsage = "usage"
)

Tag constants

Variables

View Source
var (
	// ErrNotStructPointer is returned when value passed to config.Load() is not a pointer to a struct.
	ErrNotStructPointer = errors.New("value passed is not a struct pointer")

	// ErrNotStruct is returned when value passed to config.Load() is not a struct.
	ErrNotStruct = errors.New("value passed is not a struct")

	// ErrFlagHelp is returned when the commandline arguments include -h or --help.
	// Application should exit without an error as pflag handles outputting the manual.
	ErrFlagHelp = pflag.ErrHelp
)

Functions

func Load

func Load(config interface{}) error

Load calls the function with the same name on the global configurator instance.

func SetArgs added in v0.3.0

func SetArgs(args []string)

SetArgs calls the function with the same name on the global configurator instance.

func SetEnvPrefix

func SetEnvPrefix(prefix string)

SetEnvPrefix calls the function with the same name on the global configurator instance.

func SetName added in v0.3.0

func SetName(name string)

SetName calls the function with the same name on the global configurator instance.

Types

type Configurator

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

func NewConfigurator

func NewConfigurator() *Configurator

func (*Configurator) Load

func (c *Configurator) Load(config interface{}) error

func (*Configurator) SetArgs added in v0.3.0

func (c *Configurator) SetArgs(args []string)

SetArgs sets the command line arguments.

func (*Configurator) SetEnvPrefix

func (c *Configurator) SetEnvPrefix(prefix string)

SetEnvPrefix manually sets the environment variable prefix.

func (*Configurator) SetName added in v0.2.0

func (c *Configurator) SetName(name string)

SetName sets the application name for displaying help.

func (*Configurator) SetOutput added in v0.5.0

func (c *Configurator) SetOutput(output io.Writer)

SetOutput sets the output writer used for help text and error messages.

type Decoder added in v0.4.0

type Decoder interface {
	Decode(value string) error
}

Decoder is implemented by types that can deserialize themselves.

Jump to

Keyboard shortcuts

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