envconfig: gomodules.xyz/envconfig Index | Files

package envconfig

import "gomodules.xyz/envconfig"

Package envconfig implements decoding of environment variables based on a user defined specification. A typical use is using environment variables for configuration settings.

Index

Package Files

doc.go env_os.go envconfig.go usage.go

Constants

const (
    DefaultListFormat = "" /* 284 byte string literal not displayed */

    DefaultTableFormat = "" /* 258 byte string literal not displayed */

)

Variables

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

ErrInvalidSpecification indicates that a specification is of the wrong type.

func CheckDisallowed Uses

func CheckDisallowed(prefix string, spec interface{}) error

CheckDisallowed 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.

func Load Uses

func Load(prefix string, spec interface{}, loader LoaderFunc) error

Load populates the specified struct based on loader function

func MustLoad Uses

func MustLoad(prefix string, spec interface{}, loader LoaderFunc)

MustLoad is the same as Load but panics if an error occurs

func MustProcess Uses

func MustProcess(prefix string, spec interface{})

MustProcess is the same as Process but panics if an error occurs

func Process Uses

func Process(prefix string, spec interface{}) error

Process populates the specified struct based on environment variables

func Usage Uses

func Usage(prefix string, spec interface{}) error

Usage writes usage information to stderr using the default header and table format

func Usagef Uses

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

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

func Usaget Uses

func Usaget(prefix string, spec interface{}, out io.Writer, tmpl *template.Template) error

Usaget writes usage information to the specified io.Writer using the specified template

type Decoder Uses

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 LoaderFunc Uses

type LoaderFunc func(key string) (value string, found bool)

LoaderFunc returns value for a given key

type ParseError Uses

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

A ParseError occurs when an environment variable cannot be converted to the type required by a struct field during assignment.

func (*ParseError) Error Uses

func (e *ParseError) Error() string

type Setter Uses

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.

Package envconfig imports 12 packages (graph) and is imported by 47 packages. Updated 2019-03-08. Refresh now. Tools for package owners.