Skip to content
/ boa Public

minimalist configuration library for go

License

Notifications You must be signed in to change notification settings

feliixx/boa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Report Card codecov PkgGoDev

boa

A small configuration library for go application with a viper-like API, but with limited scope and no external dependency

It supports:

  • reading a config in JSON or JSONC ( JSON with comments)
  • setting default

example

config := `
{
  "http_server": {
    "enabled": true,
    "host": "127.0.0.1"
  }
}`

boa.SetDefault("http_server.port", 80)

err := boa.ParseConfig(strings.NewReader(config))
if err != nil {
	log.Fatal(err)
}

srvHost := boa.GetString("http_server.host")
srvPort := boa.GetInt("http_server.port")

fmt.Printf("%s:%d", srvHost, srvPort)
// Output: 127.0.0.1:80