Documentation ¶
Index ¶
- func ParseDuration(s string) (time.Duration, error)
- type Loader
- type Settings
- func (s *Settings) GetBool(key string) (bool, bool)
- func (s *Settings) GetDuration(key string) (time.Duration, bool)
- func (s *Settings) GetFloat(key string) (float64, bool)
- func (s *Settings) GetInt(key string) (int, bool)
- func (s *Settings) GetKeys() (res []string)
- func (s *Settings) GetString(key string) (string, bool)
- func (s *Settings) Has(key string) bool
- func (s *Settings) Load(loaders ...Loader) error
- func (s *Settings) Unmarshal(destinationPtr interface{}) error
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 Loader ¶
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
func NewStringLoader ¶
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
func (*Settings) 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 (*Settings) 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 (*Settings) 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 (*Settings) 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 (*Settings) 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