Documentation ¶
Overview ¶
Package cfgx
This package provides functions to load configuration items in specified configuration file. The configuration file will be probed in the order of:
./sdp.conf ./conf/sdp.conf ./conf/sdp/sdp.conf ./cfg/sdp.conf ./cfg/sdp/sdp.conf ./etc/sdp.conf ./etc/sdp/sdp.conf /etc/sdp.conf /etc/sdp/sdp.conf /user/local/etc/sdp.conf /user/local/etc/sdp/sdp.conf
When one of the file in the above list is found, the rest of other files will be ignored.
We can use cfgx.AsInt() to parse configuration value as an int value. See cfgx.AsXxxx() for more information.
Index ¶
- func AsBool(key string, dst *bool, def bool) error
- func AsDuration(key string, dst *time.Duration, def time.Duration) error
- func AsInt[T valuex.IntType](key string, dst *T, def T) error
- func AsStr(key string, dst *string, def string) error
- func AsStrArray(key string, dst *[]string, def []string) error
- func AsUint[T valuex.UintType](key string, dst *T, def T) error
- func PanicIf[T any](ret T, src string, err error) (T, error)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsDuration ¶ added in v0.0.14
Types ¶
type Config ¶ added in v0.0.14
type Config struct { // The user-specified configuration file name. // We can do parse os.args to pick the configuration file arguments. CfgFile string // Whether raise a panic when errors found or not. If PanicWithError is true // this module, cfgx, will raise a panic and exit the program when errors found. // // Otherwise, cfgx do nothing but returns a empty value set. PanicWithError bool }
Click to show internal directories.
Click to hide internal directories.