envconf

package module
v0.1.71 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

func NewConfig

func NewConfig() *Config

NewConfig returns an envconf.Config that is used to read configuration from environment variables. The environment variables are stored in envconf.Config, so changes to the environment after NewConfig has been called will not be taken into account.

func (*Config) Define

func (c *Config) Define(key string, dtype DataType)

Define the type of an environment variable. Variables without a defined type will be ignored by Parse.

func (*Config) DefineDefault

func (c *Config) DefineDefault(key string, val string, dtype DataType)

Define the type and default value of an environment variable. Variables without a defined type will be ignored by Parse.

func (*Config) DefineMap added in v0.1.41

func (c *Config) DefineMap(key string, dtype DataType)

Define the type of an environment variable. Variables without a defined type will be ignored by Parse.

func (*Config) GetBool

func (c *Config) GetBool(key string) bool

Returns the value of an environment variable. If the variable is not defined as envconf.TypeBool the function will return false.

func (*Config) GetDirectory added in v0.1.13

func (c *Config) GetDirectory(key string) string

Returns the value of an environment variable. If the variable is not defined as envconf.TypeDirectory the function will return the empty string.

func (*Config) GetDuration

func (c *Config) GetDuration(key string) time.Duration

Returns the value of an environment variable. If the variable is not defined as envconf.TypeDuration the function will return time.Duration(0).

func (*Config) GetHex added in v0.1.49

func (c *Config) GetHex(key string) []byte

Returns the value of an environment variable. If the variable is not defined as envconf.TypeHex the function will return []byte{}.

func (*Config) GetInt

func (c *Config) GetInt(key string) int64

Returns the value of an environment variable. If the variable is not defined as envconf.TypeInt the function will return 0.

func (*Config) GetMapBool added in v0.1.41

func (c *Config) GetMapBool(key string) (empty map[string]bool)

func (*Config) GetMapDirectory added in v0.1.71

func (c *Config) GetMapDirectory(key string) (empty map[string]string)

func (*Config) GetMapDuration added in v0.1.41

func (c *Config) GetMapDuration(key string) (empty map[string]time.Duration)

func (*Config) GetMapHex added in v0.1.49

func (c *Config) GetMapHex(key string) (empty map[string][]byte)

func (*Config) GetMapInt added in v0.1.41

func (c *Config) GetMapInt(key string) (empty map[string]int64)

func (*Config) GetMapMapBool added in v0.1.60

func (c *Config) GetMapMapBool(key string) (empty map[string]map[string]bool)

func (*Config) GetMapMapDirectory added in v0.1.71

func (c *Config) GetMapMapDirectory(key string) (empty map[string]map[string]string)

func (*Config) GetMapMapDuration added in v0.1.60

func (c *Config) GetMapMapDuration(key string) (empty map[string]map[string]time.Duration)

func (*Config) GetMapMapHex added in v0.1.60

func (c *Config) GetMapMapHex(key string) (empty map[string]map[string][]byte)

func (*Config) GetMapMapInt added in v0.1.60

func (c *Config) GetMapMapInt(key string) (empty map[string]map[string]int64)

func (*Config) GetMapMapMapBool added in v0.1.60

func (c *Config) GetMapMapMapBool(key string) (empty map[string]map[string]map[string]bool)

func (*Config) GetMapMapMapDirectory added in v0.1.71

func (c *Config) GetMapMapMapDirectory(key string) (empty map[string]map[string]map[string]string)

func (*Config) GetMapMapMapDuration added in v0.1.60

func (c *Config) GetMapMapMapDuration(key string) (empty map[string]map[string]map[string]time.Duration)

func (*Config) GetMapMapMapHex added in v0.1.60

func (c *Config) GetMapMapMapHex(key string) (empty map[string]map[string]map[string][]byte)

func (*Config) GetMapMapMapInt added in v0.1.60

func (c *Config) GetMapMapMapInt(key string) (empty map[string]map[string]map[string]int64)

func (*Config) GetMapMapMapMapBool added in v0.1.70

func (c *Config) GetMapMapMapMapBool(key string) (empty map[string]map[string]map[string]map[string]bool)

func (*Config) GetMapMapMapMapDirectory added in v0.1.71

func (c *Config) GetMapMapMapMapDirectory(key string) (empty map[string]map[string]map[string]map[string]string)

func (*Config) GetMapMapMapMapDuration added in v0.1.70

func (c *Config) GetMapMapMapMapDuration(key string) (empty map[string]map[string]map[string]map[string]time.Duration)

func (*Config) GetMapMapMapMapHex added in v0.1.70

func (c *Config) GetMapMapMapMapHex(key string) (empty map[string]map[string]map[string]map[string][]byte)

func (*Config) GetMapMapMapMapInt added in v0.1.70

func (c *Config) GetMapMapMapMapInt(key string) (empty map[string]map[string]map[string]map[string]int64)

func (*Config) GetMapMapMapMapMapBool added in v0.1.70

func (c *Config) GetMapMapMapMapMapBool(key string) (empty map[string]map[string]map[string]map[string]map[string]bool)

func (*Config) GetMapMapMapMapMapDirectory added in v0.1.71

func (c *Config) GetMapMapMapMapMapDirectory(key string) (empty map[string]map[string]map[string]map[string]map[string]string)

func (*Config) GetMapMapMapMapMapDuration added in v0.1.70

func (c *Config) GetMapMapMapMapMapDuration(key string) (empty map[string]map[string]map[string]map[string]map[string]time.Duration)

func (*Config) GetMapMapMapMapMapHex added in v0.1.70

func (c *Config) GetMapMapMapMapMapHex(key string) (empty map[string]map[string]map[string]map[string]map[string][]byte)

func (*Config) GetMapMapMapMapMapInt added in v0.1.70

func (c *Config) GetMapMapMapMapMapInt(key string) (empty map[string]map[string]map[string]map[string]map[string]int64)

func (*Config) GetMapMapMapMapMapMetric added in v0.1.71

func (c *Config) GetMapMapMapMapMapMetric(key string) (empty map[string]map[string]map[string]map[string]map[string]int64)

func (*Config) GetMapMapMapMapMapString added in v0.1.70

func (c *Config) GetMapMapMapMapMapString(key string) (empty map[string]map[string]map[string]map[string]map[string]string)

func (*Config) GetMapMapMapMapMetric added in v0.1.71

func (c *Config) GetMapMapMapMapMetric(key string) (empty map[string]map[string]map[string]map[string]int64)

func (*Config) GetMapMapMapMapString added in v0.1.70

func (c *Config) GetMapMapMapMapString(key string) (empty map[string]map[string]map[string]map[string]string)

func (*Config) GetMapMapMapMetric added in v0.1.71

func (c *Config) GetMapMapMapMetric(key string) (empty map[string]map[string]map[string]int64)

func (*Config) GetMapMapMapString added in v0.1.60

func (c *Config) GetMapMapMapString(key string) (empty map[string]map[string]map[string]string)

func (*Config) GetMapMapMetric added in v0.1.71

func (c *Config) GetMapMapMetric(key string) (empty map[string]map[string]int64)

func (*Config) GetMapMapString added in v0.1.60

func (c *Config) GetMapMapString(key string) (empty map[string]map[string]string)

func (*Config) GetMapMetric added in v0.1.71

func (c *Config) GetMapMetric(key string) (empty map[string]int64)

func (*Config) GetMapString added in v0.1.41

func (c *Config) GetMapString(key string) (empty map[string]string)

func (*Config) GetMetric added in v0.1.20

func (c *Config) GetMetric(key string) int64

Returns the value of an environment variable. If the variable is not defined as envconf.TypeMetric the function will return 0.

func (*Config) GetString

func (c *Config) GetString(key string) string

Returns the value of an environment variable. If the variable is not defined as envconf.TypeString the function will return the empty string.

func (*Config) Parse

func (c *Config) Parse()

Parse parses the environment variables previously defined by Define and DefineDefault. Parse should only be called once for a given envconf.Config.

func (*Config) Status

func (c *Config) Status() (ok bool)

Status prints out failures that occured while parsing the environment to os.Stderr. Variables that have been defined without a default value and are missing from the environment will be considered a failure. If parsing of any of the variables has failed Status will return false.

func (*Config) StatusHelp added in v0.1.36

func (c *Config) StatusHelp() bool

type DataType

type DataType uint32
const (
	TypeNone      DataType = iota << 16
	TypeInt       DataType = iota << 16
	TypeMetric    DataType = iota << 16
	TypeDuration  DataType = iota << 16
	TypeString    DataType = iota << 16
	TypeDirectory DataType = iota << 16
	TypeBool      DataType = iota << 16
	TypeHex       DataType = iota << 16
)

func FixedHex added in v0.1.52

func FixedHex(size uint16) DataType

func (DataType) String

func (dtype DataType) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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