Documentation ¶
Index ¶
- func Bool(key string) (bool, error)
- func Duration(key string) (time.Duration, error)
- func Init(p Provider) error
- func Int(key string) (int, error)
- func Log() string
- func MustBool(key string) bool
- func MustDuration(key string) time.Duration
- func MustInt(key string) int
- func MustString(key string) string
- func MustTime(key string) time.Time
- func MustURL(key string) *url.URL
- func SetBool(key string, value bool)
- func SetDuration(key string, value time.Duration)
- func SetInt(key string, value int)
- func SetString(key string, value string)
- func SetTime(key string, value time.Time)
- func SetURL(key string, value *url.URL)
- func String(key string) (string, error)
- func Time(key string) (time.Time, error)
- func URL(key string) (*url.URL, error)
- type Config
- func (c *Config) Bool(key string) (bool, error)
- func (c *Config) Duration(key string) (time.Duration, error)
- func (c *Config) Int(key string) (int, error)
- func (c *Config) Log() string
- func (c *Config) MustBool(key string) bool
- func (c *Config) MustDuration(key string) time.Duration
- func (c *Config) MustInt(key string) int
- func (c *Config) MustString(key string) string
- func (c *Config) MustTime(key string) time.Time
- func (c *Config) MustURL(key string) *url.URL
- func (c *Config) SetBool(key string, value bool)
- func (c *Config) SetDuration(key string, value time.Duration)
- func (c *Config) SetInt(key string, value int)
- func (c *Config) SetString(key string, value string)
- func (c *Config) SetTime(key string, value time.Time)
- func (c *Config) SetURL(key string, value *url.URL)
- func (c *Config) String(key string) (string, error)
- func (c *Config) Time(key string) (time.Time, error)
- func (c *Config) URL(key string) (*url.URL, error)
- type FileProvider
- type Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool calls the default Config and returns the bool value of a given key as a bool. It will return an error if the key was not found or the value can't be converted to a bool.
func Duration ¶
Duration calls the default Config and returns the value of the given key as a duration. It will return an error if the key was not found or the value can't be converted to a Duration.
func Init ¶
Init populates the package's default Config and should be called only once. A Provider must be supplied which will return a map of key/value pairs to be loaded.
func Int ¶
Int calls the Default config and returns the value of the given key as an int. It will return an error if the key was not found or the value can't be converted to an int.
func Log ¶
func Log() string
Log returns a string to help with logging the package's default Config. It excludes any values whose key contains the string "PASS".
func MustBool ¶
MustBool calls the default Config and returns the bool value of a given key as a bool. It will panic if the key was not found or the value can't be converted to a bool.
func MustDuration ¶
MustDuration calls the default Config and returns the value of the given key as a MustDuration. It will panic if the key was not found or the value can't be converted to a MustDuration.
func MustInt ¶
MustInt calls the default Config and returns the value of the given key as an int. It will panic if the key was not found or the value can't be converted to an int.
func MustString ¶
MustString calls the default Config and returns the value of the given key as a string, else it will panic if the key was not found.
func MustTime ¶
MustTime calls the default Config ang returns the value of the given key as a Time. It will panic if the key was not found or the value can't be converted to a Time.
func MustURL ¶
MustURL calls the default Config and returns the value of the given key as a URL. It will panic if the key was not found or the value can't be converted to a URL.
func SetDuration ¶
SetDuration adds or modifies the default Config for the specified key and value.
func String ¶
String calls the default Config and returns the value of the given key as a string. It will return an error if key was not found.
Types ¶
type Config ¶
func DefaultConfig ¶
func DefaultConfig() *Config
func (*Config) Bool ¶
Bool returns the bool value of a given key as a bool. It will return an error if the key was not found or the value can't be converted to a bool.
func (*Config) Duration ¶
Duration returns the value of the given key as a Duration. It will return an error if the key was not found or the value can't be converted to a Duration.
func (*Config) Int ¶
Int returns the value of the given key as an int. It will return an error if the key was not found or the value can't be converted to an int.
func (*Config) MustBool ¶
MustBool returns the bool value of a given key as a bool. It will panic if the key was not found or the value can't be converted to a bool.
func (*Config) MustDuration ¶
MustDuration returns the value of the given key as a Duration. It will panic if the key was not found or the value can't be converted into a Duration.
func (*Config) MustInt ¶
MustInt returns the value of the given key as an int. It will panic if the key was not found or the value can't be converted to an int.
func (*Config) MustString ¶
MustString returns the value of the given key as a string. It will panic if the key was not found.
func (*Config) MustTime ¶
MustTime returns the value of the given key as a Time. It will panic if the key was not found or the value can't be converted to a Time.
func (*Config) MustURL ¶
MustURL returns the value of the given key as a URL. It will panic if the key was not found or the value can't be converted to a URL.
func (*Config) SetBool ¶
SetBool adds or modifies the configuration for the specified key and value.
func (*Config) SetDuration ¶
SetDuration adds or modifies the configuration for a given duration at a specific key.
func (*Config) SetString ¶
SetString adds or modifies the configuration for the specified key and value.
func (*Config) SetTime ¶
SetTime adds or modifies the configuration for the specified key and value.
func (*Config) String ¶
String returns the value of the given key as a string. It will return an error if key was not found.
type FileProvider ¶
type FileProvider struct {
Filename string
}
FileProvider describes a file based loader which loads the configuration from a file listed.
func NewFileProvider ¶
func NewFileProvider(name *string) *FileProvider