Documentation
¶
Index ¶
- func Bool(c *Config, name string) bool
- func BoolSafe(c *Config, name string) bool
- func DebugValue(c *Config, name string) interface{}
- func Duration(c *Config, name string) time.Duration
- func DurationSafe(c *Config, name string) time.Duration
- func Int(c *Config, name string) int64
- func IntSafe(c *Config, name string) int64
- func String(c *Config, name string) string
- func StringSafe(c *Config, name string) string
- func StringSlice(c *Config, name string) []string
- func StringSliceSafe(c *Config, name string) []string
- func Uint(c *Config, name string) uint64
- func UintSafe(c *Config, name string) uint64
- type Config
- type Option
- type Prm
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool reads configuration value from c by name and casts it to bool.
Panics if value can not be casted.
func BoolSafe ¶
BoolSafe reads configuration value from c by name and casts it to bool.
Returns false if value can not be casted.
func DebugValue ¶
DebugValue returns debug configuration value.
Returns nil if misc.Debug is not set to "true".
func Duration ¶
Duration reads configuration value from c by name and casts it to time.Duration.
Panics if value can not be casted.
func DurationSafe ¶
DurationSafe reads configuration value from c by name and casts it to time.Duration.
Returns 0 if value can not be casted.
func Int ¶
Int reads configuration value from c by name and casts it to int64.
Panics if value can not be casted.
func IntSafe ¶
IntSafe reads configuration value from c by name and casts it to int64.
Returns 0 if value can not be casted.
func String ¶
String reads configuration value from c by name and casts it to string.
Panics if value can not be casted.
func StringSafe ¶
StringSafe reads configuration value from c by name and casts it to string.
Returns "" if value can not be casted.
func StringSlice ¶
StringSlice reads configuration value from c by name and casts it to []string.
Panics if value can not be casted.
func StringSliceSafe ¶
StringSliceSafe reads configuration value from c by name and casts it to []string.
Returns nil if value can not be casted.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents a group of named values structured by tree type.
Sub-trees are named configuration sub-sections, leaves are named configuration values. Names are of string type.
func New ¶
New creates a new Config instance.
If file option is provided (WithConfigFile), configuration values are read from it. Otherwise, Config is a degenerate tree.
type Option ¶
type Option func(*opts)
Option allows to set optional parameter of the Config.
func WithConfigFile ¶
WithConfigFile returns option to set system path to the configuration file.