This package is a simple json configuration decoder into struct.
go get github.com/petechu/gojsonconf
// conf.json
{
"Port": "3000",
"Host": "example.com"
}
type Conf Struct {
Port string
Host string
}
conf := Conf{}
err := gojsonconf.GetConfig("conf.json", &conf)
if err != nil {
// do something
}
fmt.Println(conf.Port) // 3000
fmt.Println(conf.Host) // example.com
// conf.json
{
"port": "3000",
"host": "example.com"
}
type Conf Struct {
Port string `json:"port"`
Host string `json:"host"`
}
conf := Conf{}
err := gojsonconf.GetConfig("conf.json", &conf)
if err != nil {
// do something
}
fmt.Println(conf.Port) // 3000
fmt.Println(conf.Host) // example.com