Skip to content

A powerful configuration package for go using Loose JSON as the format

License

Notifications You must be signed in to change notification settings

daviddengcn/go-ljson-conf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-ljson-conf GoSearch

A powerful configuration package for go using Loose JSON as the format. (godoc)

Features

Data format

The data format is the Loose JSON, which is full compatible with JSON format but more easier for writing by hand. Visit Loose JSON project for more details.

Lines starting with // or ; (excluding the leading spaces) are considered as comments and thus ignored.

Dot-seperated hierarchical key

For configure:

{
	// http settings
	http: {
		addr: "www.example.com"
		ports: [80, 8080]
	}
}

You can fetch values by different ways:

code value type
String("http.addr") "www.example.com" string
IntList("http.ports") [80, 8080] []int
Int("http.ports[1]") 8080 int
Object("http") map[addr:www...] map[string]interface{}

Include function

main.conf

{
	http: {
		#include#: "addr.conf"
	}
}

addr.conf

{
	addr: "www.example.com"
	ports: [80, 8080]
}

we got:

{
	http: {
		addr: "www.example.com"
		ports: [80, 8080]
	}
}

Multi-path searching We calling Load function, it searches the following path in order:

  1. For absolute path, it is directly used,
  2. Current directory,
  3. Directory of the executable, and
  4. User's home directory

LICENSE

BSD license.

About

A powerful configuration package for go using Loose JSON as the format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published