aconfig alternatives and similar packages
Based on the "Configuration" category.
Alternatively, view aconfig alternatives based on common mentions on social networks and blogs.
-
kelseyhightower/envconfig
Go library for managing configuration data from environment variables. -
konfig
Composable, observable and performant config handling for Go for the distributed processing era. -
koanf
Light weight, extensible library for reading config in Go applications. Built in support for JSON, TOML, YAML, env, command line. -
confita
Load configuration in cascade from multiple backends into a struct. -
config
JSON or YAML configuration wrapper with environment variables and flags parsing. -
cleanenv
Minimalistic configuration reader (from files, ENV, and wherever you want). -
gookit/config
application config manage(load,get,set). support JSON, YAML, TOML, INI, HCL. multi file load, data override merge. -
hjson
Human JSON, a configuration file format for humans. Relaxed syntax, fewer mistakes, more comments. -
gcfg
read INI-style configuration files into Go structs; supports user-defined types and subsections -
joshbetz/config
A small configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP. -
goConfig
Parse a struct as input and populates the fields of this struct with parameters fom command line, environment variables and configuration file. -
harvester
Harvester, a easy to use static and dynamic configuration package supportig seeding, env vars and Consul integration. -
onion
Layer based configuration for Go, Supports JSON, TOML, YAML, properties, etcd, env, and encryption using PGP. -
configuro
opinionated configuration loading & validation framework from ENV and Files focused towards 12-Factor compliant applications. -
configure
Provides configuration through multiple sources, including JSON, flags and environment variables. -
configuration
Library for initializing configuration structs from env variables, files, flags and 'default' tag. -
go-up
A simple configuration library with recursive placeholders resolution and no magic. -
hocon
Configuration library for working with the HOCON(a human-friendly JSON superset) format, supports features like environment variables, referencing other values, comments and multiple files. -
CONFLATE
Library providing routines to merge and validate JSON, YAML and/or TOML files -
go-ssm-config
Go utility for loading configuration parameters from AWS SSM (Parameter Store). -
swap
Instantiate/configure structs recursively, based on build environment. (YAML, TOML, JSON and env). -
sprbox
Build-environment aware toolbox factory and agnostic config parser (YAML, TOML, JSON and Environment vars). -
typenv
Minimalistic, zero dependency, typed environment variables library. -
gonfig
Tag-based configuration parser which loads values from different providers into typesafe struct. -
nasermirzaei89/env
Simple useful package for read environment variables. -
txgruppi-config
Quick and easy way to load config files based on a simple set of rules. -
gone/jconf
Modular JSON configuration. Keep you config structs along the code they configure and delegate parsing to submodules without sacrificing full config serialization.
Scout APM - Leading-edge performance monitoring starting at $39/month
Do you think we are missing an alternative of aconfig or a related project?
Popular Comparisons
README
aconfig
Simple, useful and opinionated config loader.
Rationale
There are more than 2000 repositories on Github regarding configuration in Go. I was looking for a simple configuration loader that will automate a lot of things for me. Idea was to load config from 4 common places: defaults (in the code), config files, environment variables, command-line flags. This library works with all of them.
Features
- Simple API.
- Automates a lot of things.
- config params names
- config loading
- generates documentation
- Opinionated.
- Supports different sources:
- defaults in code
- files (JSON, YAML, TOML)
- environment variables
- command-line flags
- Dependency-free (except file parsers).
- Walk over configuration fields.
Install
Go version 1.14+
go get github.com/cristalhq/aconfig
Example
type MyConfig struct {
Port int `default:"1111" usage:"just give a number"`
Auth struct {
User string `default:"def-user"`
Pass string `default:"def-pass"`
}
Pass string `default:"" env:"SECRET" flag:"sec_ret"`
}
var cfg MyConfig
loader := aconfig.LoaderFor(&cfg).
// feel free to skip some steps :)
// SkipDefaults().
// SkipFiles().
// SkipEnvironment().
// SkipFlags().
WithFiles([]string{"file.json", "ouch.yaml"}).
WithEnvPrefix("APP").
WithFlagPrefix("app").
Build()
flagSet := loader.Flags() // Important: use exactly this flags to define your own
if err := loader.Load(); err != nil {
panic(err)
}
// configuration fields will be loaded from (in order):
//
// 1. defaults set in structure tags (see structure defenition)
// 2. loaded from files `file.json` if not `ouch.yaml` will be used
// 3. from corresponding environment variables with the prefix `APP_`
// 4. command-line flags with the prefix `app.` if they are
Also see examples: examples_test.go.
Integration with spf13/cobra
playground.
Documentation
See here: pkg.go.dev.
License
[MIT License](LICENSE).
*Note that all licence references and agreements mentioned in the aconfig README section above
are relevant to that project's source code only.