envvar

package
v0.157.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigReader

type ConfigReader interface {
	// Get returns an interface{}.
	// For a specific value use one of the Get____ methods.
	Get(key string) (interface{}, error)

	// GetString retrieves the associated key value as a string.
	GetString(key string) (string, error)

	// Unmarshal deserializes the loaded cofig into a struct.
	Unmarshal(config interface{}) error
}

ConfigReader lists the methods exposed by ConfigReaderImpl.

type ConfigReaderBuilder

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

ConfigReaderBuilder exposes the builder api for configReaderImpl. Use NewConfigReaderBuilder() and AttachEnvPrefix() to build a ConfigReaderBuilder. Follow it up one or more calls to WithConfigFile() and/or WithConfigName() and finally use Build() to build the configReaderImpl.

func NewConfigReaderBuilder

func NewConfigReaderBuilder() ConfigReaderBuilder

NewConfigReaderBuilder builds a new ConfigReaderBuilder.

func (ConfigReaderBuilder) AttachEnvPrefix

func (b ConfigReaderBuilder) AttachEnvPrefix(appName string) ConfigReaderBuilder

AttachEnvPrefix attaches appName as prefix.

func (ConfigReaderBuilder) Build

Build Builds and returns the ConfigReader.

func (ConfigReaderBuilder) WithConfigFile

func (b ConfigReaderBuilder) WithConfigFile(configFile string) ConfigReaderBuilder

WithConfigFile attaches the passed config file.

func (ConfigReaderBuilder) WithConfigName

func (b ConfigReaderBuilder) WithConfigName(configName string, configPath ...string) ConfigReaderBuilder

WithConfigName attaches the passed config path and name.

func (ConfigReaderBuilder) WithFs

WithFs attaches the file system to use.

func (ConfigReaderBuilder) WithStrictMode added in v0.143.0

func (b ConfigReaderBuilder) WithStrictMode(strict bool, ignoredKeys ...string) ConfigReaderBuilder

WithStrictMode controls if ConfigReader.Unmarshal handles unknown keys. If strict mode is false (the default), config keys with no corresponding config field are ignored. If strict mode is true, any config key with no corresponding config field will be regarded as a decoding error that will cause Unmarshal to return an error.

Also, optionally, a list of keys to ignore and exclude from strict mode checking can be provided. Beware, there's some subtleties to how ignored keys must be named, see the comments inside configreaderimpl.go for details.

type NilValueError

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

NilValueError is raised when the key value is nil.

func (NilValueError) Error

func (e NilValueError) Error() string

type ValueConversionError

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

ValueConversionError is raised when the key value is incompatible with the invoked method.

func (ValueConversionError) Error

func (e ValueConversionError) Error() string

Jump to

Keyboard shortcuts

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