go get github.com/goburrow/cfg
- example.go
package main
import (
"fmt"
"github.com/goburrow/cfg"
)
func main() {
keys := make(map[string]string)
// DefaultLoader loads configuration from ini file "~/.config/myApp/config"
// if it exists and environment variables starting with "myApp_".
loader := cfg.DefaultLoader("myApp")
err := loader.Load(keys)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(keys)
}
- ~/.config/myApp/config
x = 0
y = 0
[point1]
x = 1
y = 2
- Run:
$ env myApp_y=1 myApp_point1.x=3 ./example
map[x:0 y:1 point1.x:3 point1.y:2]