https://github.com/xwi88/config4go
config files read for go with module support, if want vendor dir ref https://github.com/xwi88/config
https://github.com/xwi88/config4go
config go json module toml yaml
Last synced: 3 months ago
JSON representation
config files read for go with module support, if want vendor dir ref https://github.com/xwi88/config
- Host: GitHub
- URL: https://github.com/xwi88/config4go
- Owner: xwi88
- License: mit
- Created: 2018-12-23T09:20:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-02T14:49:14.000Z (about 5 years ago)
- Last Synced: 2025-01-15T17:36:59.200Z (4 months ago)
- Topics: config, go, json, module, toml, yaml
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# config
If you use govendor or blocked by the GFW, you can ref `https://github.com/xwi88/config`.
The rep support module and without vendor dir.
## support
support files with extension: json, toml, yaml, yml, properties, props, prop, hcl.
## usage
`go get -u github.com/xwi88/config4go`
## tips
If go get timeout, you can try set follows:
```bash
export GO111MODULE=on #go1.12 default set on
export GOPROXY=https://goproxy.io
```## example
```go
type redisOptions struct {
Host string
Port string
Password string
IdleTimeout int
MaxIdle int
MaxActive int
}type testConf struct {
Name string
Redis redisOptions
}var conf map[string]interface{}
testfile := "./testdata/app_test.toml"
err := LoadConfig(testfile, &conf)
if err != nil {
// some deal
}
fmt.Println(conf.Host)
```