Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arkan/dotconfig
Config for Go apps stored in ~/.config/app/config.yml
https://github.com/arkan/dotconfig
configuration go
Last synced: 21 days ago
JSON representation
Config for Go apps stored in ~/.config/app/config.yml
- Host: GitHub
- URL: https://github.com/arkan/dotconfig
- Owner: arkan
- License: mit
- Created: 2017-04-29T16:20:24.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-29T16:29:40.000Z (almost 8 years ago)
- Last Synced: 2024-12-02T02:39:51.302Z (3 months ago)
- Topics: configuration, go
- Language: Go
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dotconfig
Package dotconfig provides an easy way to load/save configuration to the ~/.config/APP_NAME/config.yml file.
[](https://godoc.org/github.com/arkan/dotconfig)
[](https://goreportcard.com/report/github.com/arkan/dotconfig)## Usage
```go
type settings struct {
Name string `yaml:"name"`
Endpoint string `yaml:"endpoint"`
Token string `yaml:"token"`
}ss := settings{}
if err := dotconfig.Load("my-app", &ss); err != nil {
if err == dotconfig.ErrConfigNotFound {
ss.Name = "Name"
ss.Endpoint = "http://google.com"
ss.Token = "Some token"
if err := dotconfig.Save("my-app", ss); err != nil {
panic(err)
}
}
}else if err != nil {
panic(err)
}fmt.Printf("Hello %v\n", ss.Name)
```
See the [documentation](https://godoc.org/github.com/arkan/dotconfig) for information.
## Licence
[MIT](./LICENSE)