All Projects → gosidekick → Goconfig

gosidekick / Goconfig

Licence: mit
goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configuration file.

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Goconfig

Coolie
Coolie(苦力) helps you to create models (& their constructors) from a JSON file.
Stars: ✭ 508 (+247.95%)
Mutual labels:  struct, json
Jkt
Simple helper to parse JSON based on independent schema
Stars: ✭ 22 (-84.93%)
Mutual labels:  struct, json
Jsonnet
Jsonnet - The data templating language
Stars: ✭ 5,257 (+3500.68%)
Mutual labels:  config, json
Quicklib
Quick development library (AutoMapper, LinQ, IOC Dependency Injection, MemoryCache, Scheduled tasks, Config, Serializers, etc) with crossplatform support for Delphi/Firemonkey (Windows,Linux,OSX/IOS/Android) and freepascal (Windows/Linux).
Stars: ✭ 274 (+87.67%)
Mutual labels:  config, json
Data Store
Easily get, set and persist config data. Fast. Supports dot-notation in keys. No dependencies.
Stars: ✭ 120 (-17.81%)
Mutual labels:  config, json
Airframe
Essential Building Blocks for Scala
Stars: ✭ 442 (+202.74%)
Mutual labels:  config, json
Dasel
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Stars: ✭ 759 (+419.86%)
Mutual labels:  config, json
Config
📝 Go config manage(load,get,set). support JSON, YAML, TOML, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Go应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名
Stars: ✭ 225 (+54.11%)
Mutual labels:  config, json
Cfg Center
高性能配置读取服务器,为Yaml配置文件提供JSON RESTful读取接口
Stars: ✭ 39 (-73.29%)
Mutual labels:  config, json
Mconfig
MCONFIG is a lightweight Golang library for integrating configs files like (json, yml, toml) and environment variables into one config struct.
Stars: ✭ 28 (-80.82%)
Mutual labels:  config, json
X2struct
Convert between json string and c++ object. json字符串和c++结构体之间互相转换
Stars: ✭ 251 (+71.92%)
Mutual labels:  struct, json
Cfgdiff
diff(1) all your configs
Stars: ✭ 138 (-5.48%)
Mutual labels:  config, json
Vscode Data Preview
Data Preview 🈸 extension for importing 📤 viewing 🔎 slicing 🔪 dicing 🎲 charting 📊 & exporting 📥 large JSON array/config, YAML, Apache Arrow, Avro, Parquet & Excel data files
Stars: ✭ 245 (+67.81%)
Mutual labels:  config, json
Featureflags
🚩 Allows developers to configure feature flags, run multiple A/B tests or phase feature roll out using a JSON configuration file.
Stars: ✭ 506 (+246.58%)
Mutual labels:  config, json
Konf
A type-safe cascading configuration library for Kotlin/Java/Android, supporting most configuration formats
Stars: ✭ 225 (+54.11%)
Mutual labels:  config, json
Conf
Simple config handling for your app or module
Stars: ✭ 707 (+384.25%)
Mutual labels:  config, json
Simple Settings
A simple way to manage your project settings.
Stars: ✭ 165 (+13.01%)
Mutual labels:  config, json
Config
🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP
Stars: ✭ 203 (+39.04%)
Mutual labels:  config, json
Config Rs
⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Stars: ✭ 915 (+526.71%)
Mutual labels:  config, json
Node Convict
Featureful configuration management library for Node.js
Stars: ✭ 1,855 (+1170.55%)
Mutual labels:  config, json

goconfig

Build Status Go Report Card Test Coverage Maintainability GoDoc Go project version MIT Licensed Gitpod Ready-to-Code

goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configuration file.

Install

go get github.com/gosidekick/goconfig

Example

package main

import "github.com/gosidekick/goconfig"

/*
step 1: Declare your configuration struct,
it may or may not contain substructures.
*/

type mongoDB struct {
	Host string `cfgDefault:"example.com" cfgRequired:"true"`
	Port int    `cfgDefault:"999"`
}

type configTest struct {
	Domain    string
	DebugMode bool `json:"db" cfg:"db" cfgDefault:"false"`
	MongoDB   mongoDB
	IgnoreMe  string `cfg:"-"`
}

func main() {

	// step 2: Instantiate your structure.
	config := configTest{}

	// step 3: Pass the instance pointer to the parser
	err := goconfig.Parse(&config)
	if err != nil {
		println(err)
		return
	}

	/*
	   The parser populated your struct with the data
	   it took from environment variables and command
	   line and now you can use it.
	*/

	println("config.Domain......:", config.Domain)
	println("config.DebugMode...:", config.DebugMode)
	println("config.MongoDB.Host:", config.MongoDB.Host)
	println("config.MongoDB.Port:", config.MongoDB.Port)
}

With the example above try environment variables like $DOMAIN or $MONGODB_HOST and run the example again to see what happens.

You can also try using parameters on the command line, try -h to see the help.

Contributing

  • Fork the repo on GitHub
  • Clone the project to your own machine
  • Create a branch with your modifications git checkout -b fantastic-feature.
  • Then commit your changes git commit -m 'Implementation of new fantastic feature'
  • Make a push to your branch git push origin fantastic-feature.
  • Submit a Pull Request so that we can review your changes
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].