gofigure alternatives and similar packages
Based on the "Configuration" category.
Alternatively, view gofigure alternatives based on common mentions on social networks and blogs.
-
koanf
Simple, extremely lightweight, extensible, configuration management library for Go. Support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper. -
konfig
Composable, observable and performant config handling for Go for the distributed processing era -
gookit/config
📝 Go configuration manage(load,get,set,export). support JSON, YAML, TOML, Properties, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Go应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名 -
gcfg
read INI-style configuration files into Go structs; supports user-defined types and subsections -
goConfig
DISCONTINUED. goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configuration file. -
joshbetz/config
🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP. -
configuro
An opinionated configuration loading framework for Containerized and Cloud-Native applications. -
hocon
go implementation of lightbend's HOCON configuration library https://github.com/lightbend/config -
configure
Configure is a Go package that gives you easy configuration of your project through redundancy -
Genv
Genv is a library for Go (golang) that makes it easy to read and use environment variables in your projects. It also allows environment variables to be loaded from the .env file. -
swap
Instantiate/configure structs recursively, based on build environment. (YAML, TOML, JSON and env).
InfluxDB - Purpose built for real-time analytics at any scale.
Do you think we are missing an alternative of gofigure or a related project?
Popular Comparisons
README
gofigure
Go configuration made easy!
- Just define a struct and call Gofigure
- Supports strings, ints/uints/floats, slices and nested structs
- Supports environment variables and command line flags
Requires Go 1.2+ because of differences in Go's flag package.
Example
go get github.com/ian-kent/gofigure
package main
import "github.com/ian-kent/gofigure"
type config struct {
gofigure interface{} `envPrefix:"BAR" order:"flag,env"`
RemoteAddr string `env:"REMOTE_ADDR" flag:"remote-addr" flagDesc:"Remote address"`
LocalAddr string `env:"LOCAL_ADDR" flag:"local-addr" flagDesc:"Local address"`
NumCPU int `env:"NUM_CPU" flag:"num-cpu" flagDesc:"Number of CPUs"`
Sources []string `env:"SOURCES" flag:"source" flagDesc:"Source URL (can be provided multiple times)"`
Numbers []int `env:"NUMBERS" flag:"number" flagDesc:"Number (can be provided multiple times)"`
Advanced struct{
MaxBytes int64 `env:"MAX_BYTES" flag:"max-bytes" flagDesc:"Max bytes"`
MaxErrors int64 `env:"MAX_ERRORS" flag:"max-errors" flagDesc:"Max errors"`
}
}
func main() {
var cfg config
err := gofigure.Gofigure(&cfg)
if err != nil {
log.Fatal(err)
}
// use cfg
}
gofigure field
The gofigure field is used to configure Gofigure.
The order
tag is used to set configuration source order, e.g.
environment variables first then command line options second.
Any field matching camelCase
format will be parsed into camel
and case
, and passed to the source matching camel
.
For example, the envPrefix
field is split into env
and prefix
,
and the tag value is passed to the environment variable source as
the prefix
parameter.
Arrays and environment variables
Array support for environment variables is currently experimental.
To enable it, set GOFIGURE_ENV_ARRAY=1
.
When enabled, the environment variable is split on commas, e.g.
struct {
EnvArray []string `env:"MY_ENV_VAR"`
}
MY_ENV_VAR=a,b,c
EnvArray = []string{"a", "b", "c"}
Licence
Copyright © 2014, Ian Kent (http://www.iankent.eu).
Released under MIT license, see [LICENSE](LICENSE.md) for details.
*Note that all licence references and agreements mentioned in the gofigure README section above
are relevant to that project's source code only.