Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/feliixx/boa

minimalist configuration library for go
https://github.com/feliixx/boa

configuration golang json

Last synced: 9 days ago
JSON representation

minimalist configuration library for go

Awesome Lists containing this project

README

        

[![Go Report Card](https://goreportcard.com/badge/github.com/feliixx/boa)](https://goreportcard.com/report/github.com/feliixx/boa)
[![codecov](https://codecov.io/gh/feliixx/boa/branch/main/graph/badge.svg?token=NJ3F2CR3VA)](https://codecov.io/gh/feliixx/boa)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/feliixx/boa)](https://pkg.go.dev/github.com/feliixx/boa)

## 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

```go
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
```