Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ifraixedes/go-config
Simpler Go configuration with structs.
https://github.com/ifraixedes/go-config
Last synced: 16 days ago
JSON representation
Simpler Go configuration with structs.
- Host: GitHub
- URL: https://github.com/ifraixedes/go-config
- Owner: ifraixedes
- License: mit
- Created: 2015-09-05T09:43:31.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-05T09:43:57.000Z (about 9 years ago)
- Last Synced: 2024-06-20T12:04:45.083Z (5 months ago)
- Language: Go
- Size: 102 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
[![GoDoc](https://godoc.org/github.com/tj/go-config?status.svg)](http://godoc.org/github.com/tj/go-config)
[![Build Status](https://travis-ci.org/tj/go-config.svg?branch=master)](https://travis-ci.org/tj/go-config)# go-config
Simpler Go configuration with structs.
## Features
- Declare configuration with structs and tags
- Type coercion out of the box
- Validation out of the box
- Pluggable resolvers
- Built-in resolvers (flag, env)
- Unambiguous resolution (must be specified via `from`)## Example
Source:
```go
package mainimport (
"log"
"os"
"time""github.com/tj/go-config"
)type Options struct {
Timeout time.Duration `desc:"message timeout"`
Concurrency uint `desc:"message concurrency"`
CacheSize config.Bytes `desc:"cache size in bytes"`
BatchSize uint `desc:"batch size" validate:"min=1,max=1000"`
LogLevel string `desc:"log severity level" from:"env,flag"`
}var options = &Options{
Timeout: time.Second * 5,
Concurrency: 10,
CacheSize: config.ParseBytes("100mb"),
BatchSize: 250,
}func main() {
config.MustResolve(options)
log.Printf("%+v", options)
}
```Command-line:
```
$ LOG_LEVEL=error example --timeout 10s --concurrenct 100 --cache-size 1gb
```# License
MIT