Go Simple config is an open source configuration lib for storing and accessing configuration data with minimal dependencies
go get github.com/chen-keinan/go-simple-config
- yaml
- json
- properties
- environment variables
- ini
{
"SERVER": {
"host": "127.0.0.1",
"port": "8080"
}
---
SERVER:
host: 127.0.0.1
port: '8080'
SERVER.host=127.0.0.1
SERVER.port=8080
export SERVER_HOST="127.0.0.1"
export SERVER_PORT="8080"
package main
import (
"fmt"
"github.com/chen-keinan/go-simple-config/simple"
"os"
)
func main() {
c := simple.New()
err := c.Load("config.json")
if err != nil {
fmt.Print(err.Error())
os.Exit(1)
}
fmt.Print(c.GetStringValue("SERVER.host"))
}