Skip to content

ke-da/jsonconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsonconfig

Golang JSON config file reader + parser

This simple package read config out of json file. It'll iterate through different possible environments and merge config from env with lower priority with the one exist in higher priority

main.go:

package main
import (
	"github.com/ke-da/jsonconfig"
)

func main() {
	config := jsonconfig.LoadFile("config.json")
	config.GetStr("Hello") //"Dev World"
	config.GetMapStr("mapStr") //{"Key" => "Value"} map[string]string
	config.GetStrSlice("strSlice") //["Str1", "Str2"} []string
}

config.json:

{
	"dev": {
		"hello": "Dev World",
		"arr": ["dev1","dev2"],
		"mapStr": {
			"Key": "Value"
		},
		"strSlice": [
			"Str1",
			"Str2"
		]
	},
	"test":{
		"hello": "Test World",
		"arr": ["test1","test2"]
	}
}

About

Golang JSON config file reader + parser

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages