zoie 88e39c560e update: 修改module | il y a 1 an | |
---|---|---|
.. | ||
README.md | il y a 1 an | |
flag.go | il y a 1 an | |
flag_test.go | il y a 1 an | |
options.go | il y a 1 an |
The flag source reads config from flags
We expect the use of the flag
package. Upper case flags will be lower cased. Dashes will be used as delimiters.
dbAddress := flag.String("database_address", "127.0.0.1", "the db address")
dbPort := flag.Int("database_port", 3306, "the db port)
Becomes
{
"database": {
"address": "127.0.0.1",
"port": 3306
}
}
flagSource := flag.NewSource(
// optionally enable reading of unset flags and their default
// values into config, defaults to false
IncludeUnset(true)
)
Load the source into config
// Create new config
conf := config.NewConfig()
// Load flag source
conf.Load(flagSource)