Documentation
¶
Index ¶
- Constants
- Variables
- func GetConfig() map[string]interface{}
- func Init(name, _type, path string) error
- func Load(conf interface{}) error
- func LoadFile(file string, conf interface{}) error
- func ResetConfig() error
- func SetConfig(key string, value interface{}) error
- func SetDefault(v interface{})
- func SetDefaultTag(tag string)
Constants ¶
const (
DefaultConfigType = "json"
)
Variables ¶
var ( // ConfigName holds the name of the configuration file. ConfigName = "" // ConfigType specifies the type/format of the configuration file. ConfigType = "" // ConfigPath denotes the path to the configuration file. ConfigPath = "" )
var DefaultTag string
DefaultTag is the default tag used to identify default values for struct fields.
Functions ¶
func GetConfig ¶
func GetConfig() map[string]interface{}
GetConfig retrieves all configuration settings as a map.
func Init ¶
Init initializes the configuration settings. It sets up the name, type, and path for the configuration file.
func Load ¶
func Load(conf interface{}) error
Load loads the configuration from the previously initialized file. It unmarshals the configuration into the provided conf interface.
func LoadFile ¶
LoadFile loads the configuration from a specified file. It unmarshals the configuration into the provided conf interface.
func SetConfig ¶
SetConfig sets a configuration key to a specified value. It also writes the updated configuration back to the file.
func SetDefault ¶
func SetDefault(v interface{})
SetDefault sets the default values for a given interface{}. The interface{} must be a pointer to a struct, bcs the default values are SET on the struct fields.
func SetDefaultTag ¶
func SetDefaultTag(tag string)
SetDefaultTag updates the tag used to identify default values.
Types ¶
This section is empty.