envconfig

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultListFormat constant to use to display usage in a list format
	DefaultListFormat = `` /* 245-byte string literal not displayed */

	// DefaultTableFormat constant to use to display usage in a tabular format
	DefaultTableFormat = `` /* 222-byte string literal not displayed */

)

Variables

View Source
var ErrEmptyPrefix = errors.New("prefix must be non-empty")

ErrEmptyPrefix indicates that prefix is empty.

View Source
var ErrInvalidSpecification = errors.New("specification must be a struct pointer")

ErrInvalidSpecification indicates that a specification is of the wrong type.

Functions

func FindUnknownEnvVariablesByPrefix

func FindUnknownEnvVariablesByPrefix(prefix string, spec interface{}) ([]string, error)

FindUnknownEnvVariablesByPrefix checks that no environment variables with the prefix are set that we don't know how or want to parse. This is likely only meaningful with a non-empty prefix. Returns list of unknown env variables.

func PrintUsage

func PrintUsage(spec interface{}) error

PrintUsage writes usage information to stdout using the default header and table format

func Usagef

func Usagef(spec interface{}, out io.Writer, format string) error

Usagef writes usage information to the specified io.Writer using the specifed template specification

Types

type Decoder

type Decoder interface {
	Decode(value string) error
}

Decoder has the same semantics as Setter, but takes higher precedence. It is provided for historical compatibility.

type FieldUnmarshalResult

type FieldUnmarshalResult struct {
	KeyName   string
	FieldName string
	TypeName  string
	Value     string
	Err       error
}

A FieldUnmarshalResult. Err is filled when an environment variable is required but missing or cannot be converted to the type required by a struct field during assignment.

type FieldUnmarshalResults

type FieldUnmarshalResults []FieldUnmarshalResult

func Unmarshal

func Unmarshal(spec interface{}) (FieldUnmarshalResults, error)

Unmarshal populates the specified struct based on environment variables and returns a slice with result of parsing each struct's field.

func (FieldUnmarshalResults) PrettyPrint

func (f FieldUnmarshalResults) PrettyPrint()

PrettyPrint prints verbose information about env variables specification, current values and whether it was parsed correctly.

type Setter

type Setter interface {
	Set(value string) error
}

Setter is implemented by types can self-deserialize values. Any type that implements flag.Value also implements Setter.

Jump to

Keyboard shortcuts

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