Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paultag/go-config
https://github.com/paultag/go-config
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/paultag/go-config
- Owner: paultag
- License: mit
- Created: 2015-09-01T03:19:58.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-03T16:27:05.000Z (over 9 years ago)
- Last Synced: 2024-10-14T19:21:03.870Z (3 months ago)
- Language: Go
- Size: 141 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
pault.ag/go/config
==================This package allows you define structs which both define the configuration
file format, and command line flags.```go
package mainimport (
"fmt"
"os""pault.ag/go/config"
)type Example struct {
Option string `flag:"option" description:"This sets all sorts of things"`
Value int `flag:"value" description:"This is an integer value!"`
}func main() {
conf := Example{
Option: "default",
}
flags, err := config.LoadFlags("example", &conf)
// This will load the RFC822 formatted config from ~/.examplerc and
// return a flag.FlagSet. The Flags will be populated by defaults from
// the struct given.
if err != nil {
panic(err)
}
flags.Parse(os.Args[1:])
fmt.Printf("option %s, value %d\n", conf.Option, conf.Value)
}
```