Documentation ¶
Index ¶
- func ParseDuration(s string) (time.Duration, error)
- type Config
- func (c *Config) GetBool(key string) (bool, bool)
- func (c *Config) GetDuration(key string) (time.Duration, bool)
- func (c *Config) GetFloat(key string) (float64, bool)
- func (c *Config) GetInt(key string) (int, bool)
- func (c *Config) GetKeys() (res []string)
- func (c *Config) GetString(key string) (string, bool)
- func (c *Config) Has(key string) bool
- func (c *Config) Load(loaders ...Loader) error
- func (c *Config) SetWatchInterval(duration time.Duration)
- func (c *Config) StopWatch()
- func (c *Config) Unmarshal(destinationPtr interface{}) error
- type Loader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseDuration ¶
ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func (*Config) GetBool ¶
GetBool returns the value at the given key parsed as bool and true if the key exists or false and false if the key doesn't exist or failed to parse as a truthy value
func (*Config) GetDuration ¶
GetDuration returns the value at the given key parsed as Duration and true if the key exists or Duration(0) and false if the key doesn't exist or failed to parse as Duration
func (*Config) GetFloat ¶
GetFloat returns the value at the given key parsed as a float and true if the key exists or 0.0 and false if the key doesn't exist or failed to parse as a float64
func (*Config) GetInt ¶
GetInt returns the value at the given key parsed as a int and true if the key exists or 0 and false if the key doesn't exist or failed to parse as a int
func (*Config) GetString ¶
GetString returns the value at the given key as a string and true if the key exists or empty string and false if the key doesn't exist
func (*Config) Load ¶
Load runs the given loaders in order to load and parse the configuration values. The first loader that returns an error stops the load process
func (*Config) SetWatchInterval ¶
SetWatchInterval sets interval of to automatic load configurations every duration, default interval is 5s
type Loader ¶
type Loader interface { // Parse method is called Parse() (map[string]string, error) // IsWatchable method should return true if you need watch this loader IsWatchable() bool }
Loader is used to load and parse configuration values from various formats and location
func NewEnvLoader ¶
NewEnvLoader returns a env vars parser
func NewFileLoader ¶
NewFileLoader returns a .conf file parser