Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Settings ¶
type Settings struct { // Environ is a slice of "key=value" pairs which defaults // to the returned value of os.Environ(). // Element without a '=' sign are ignored. // All environment variable keys read are eventually // transformed using the KeyTransform method. // It defaults to the empty string. Environ []string // KeyPrefix is a prefix to add to all keys read from // the environment. It is usually the program name to avoid // conflict with other programs in the environment. // It defaults to the empty string. KeyPrefix string }
Settings contains settings for the environment variable source.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source implements an environment variables source. Note all keys are transformed using its KeyTransform method.
func New ¶
New creates a new environment variable source given the environment as a slice of key-value pairs, which can generally be obtained with os.Environ(). Environ values with no '=' sign are ignored. All environment variable keys read are eventually transformed using the KeyTransform method.
func (*Source) Get ¶
Get returns the value of the environment variable found at the given key, and a boolean `isSet` to indicate if it is set or not.
func (*Source) KeyTransform ¶
KeyTransform transforms a generic key to an environment variable key. It notably: - Changes all characters to be uppercase - Replaces all dashes with underscores. - Prefixes the key with the KeyPrefix field, without modifying the prefix.