Documentation ¶
Overview ¶
Package goconfig uses a struct as input and populates the fields of this struct with parameters fom command line, environment variables and configuration file.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrFileFormatNotDefined = errors.New("file format not defined")
ErrFileFormatNotDefined Is the error that is returned when there is no defined configuration file format.
var File string
File name of default config file
var FileRequired bool
FileRequired config file required
var Formats []Fileformat
Formats is the list of registered formats.
var HelpString string
HelpString temporarily saves help
var Path string
Path sets default config path
var PrefixEnv string
PrefixEnv is a string that would be placed at the beginning of the generated Event tags.
var PrefixFlag string
PrefixFlag is a string that would be placed at the beginning of the generated Flag tags.
var Tag = "cfg"
Tag to set main name of field
var TagDefault = "cfgDefault"
TagDefault to set default value
var TagHelper = "cfgHelper"
TagHelper to set usage help line
var Usage func()
Usage is a function to show the help, can be replaced by your own version.
Functions ¶
func Parse ¶
func Parse(config interface{}) (err error)
Parse configuration
Example ¶
type config struct { Name string `cfg:"Name" cfgDefault:"root"` Value int `cfg:"Value" cfgDefault:"123"` } cfg := config{} err := Parse(&cfg) if err != nil { println(err) } println("Name:", cfg.Name, "Value:", cfg.Value)
Output:
Types ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
hcl_config_file
Example with configuration file.
|
Example with configuration file. |
ini_config_file
Example with configuration file.
|
Example with configuration file. |
json_config_file
Example with configuration file.
|
Example with configuration file. |
toml_config_file
Example with configuration file.
|
Example with configuration file. |
yaml_config_file
Example with configuration file.
|
Example with configuration file. |