https://github.com/octahori/gomfig
Light-weight Go library for loading configuration from JSON (strict), with a clean API and ready-to-extend design for YAML, TOML, ENV, and remote back-ends.
https://github.com/octahori/gomfig
cli-configuration config-loader configuration consul devops env etcd go go-module golang json library strict-parsing toml yaml
Last synced: 27 days ago
JSON representation
Light-weight Go library for loading configuration from JSON (strict), with a clean API and ready-to-extend design for YAML, TOML, ENV, and remote back-ends.
- Host: GitHub
- URL: https://github.com/octahori/gomfig
- Owner: octahori
- License: mit
- Created: 2025-07-10T09:46:48.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-07-10T14:24:52.000Z (11 months ago)
- Last Synced: 2025-07-10T18:19:33.237Z (11 months ago)
- Topics: cli-configuration, config-loader, configuration, consul, devops, env, etcd, go, go-module, golang, json, library, strict-parsing, toml, yaml
- Language: Go
- Homepage: https://pkg.go.dev/github.com/octahori/gomfig
- Size: 22.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# gomfig 
> Current stable: **v0.2.2** (JSON, YAML, TOML)
Light-weight, extensible Go library to load and merge configuration from multiple sources.
`gomfig` is released under semantic versioning. Version **v0.2.2** supports **JSON, YAML, and TOML** configuration files. Upcoming minor versions will introduce ENV and remote back-ends. Upcoming branches will add YAML, TOML, ENV, and remote back-ends (Consul, etcd, …).
## Features (current branch)
* Decode JSON, YAML, and TOML files/streams into arbitrary Go structs or maps.
* Strict mode for all loaders: unknown fields are rejected early.
* Minimal API:
```go
// root package convenience helpers
type JSONLoader = gomfig.JSONLoader
var cfg struct {
DB struct {
Host string `json:"host"`
Port int `json:"port"`
} `json:"db"`
}
if err := gomfig.LoadJSONFile("config.json", &cfg); err != nil {
log.Fatalf("load config: %v", err)
}
```
## Installation
```sh
go get github.com/octahori/gomfig@v0.2.2
```
## Roadmap
| Stage | Description |
|-------|-------------|
| ✓ JSON | Basic loader implementation + unit tests |
| ✓ YAML | YAML loader (`yamlcfg`, strict mode) |
| ✓ TOML | TOML loader (`tomlcfg`) |
| ☐ ENV | Map environment variables into struct with tags |
| ☐ Remote | Consul / etcd loaders |
## Contributing
1. Fork and create a feature branch.
2. Ensure `go test ./...` and `go vet ./...` pass.
3. Open a pull request.
---
Licensed under the MIT License.