Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moviestoreguy/config
Simplified configuration parsing
https://github.com/moviestoreguy/config
Last synced: 3 days ago
JSON representation
Simplified configuration parsing
- Host: GitHub
- URL: https://github.com/moviestoreguy/config
- Owner: MovieStoreGuy
- License: mit
- Created: 2020-10-21T04:40:36.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-10-21T04:41:57.000Z (about 4 years ago)
- Last Synced: 2024-10-11T18:31:23.581Z (27 days ago)
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Config
_A simple means of updating configuration provided_## Example
This package leverages previous work of utilising struct tags in order to caputre desired inputs.Environment parsing is handled by [envconfig](https://github.com/kelseyhightower/envconfig).
Flag parsing is handled by [go-flags](https://github.com/jessevdk/go-flags).In order to utilise it, you can do something like the following:
```
type Values struct {
LogLevel string `long:"log-level" description:"Set the logging level for the application"`
EnvSecret string `envconfig:"env_secret" split_words:"true"`
}func example() {
v := &Values{LogLevel: "info"}
conf := config.Default(v)
if err := conf.ParseFlags().ParseEnv().Err(); err != nil {
panic(err)
}
}
```