comment alternatives and similar packages
Based on the "Configuration" category.
Alternatively, view comment alternatives based on common mentions on social networks and blogs.
-
koanf
Simple, extremely lightweight, extensible, configuration management library for Go. Supports 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). -
sprbox
DISCONTINUED. Build-environment aware toolbox factory and agnostic config parser (YAML, TOML, JSON and Environment vars).
InfluxDB high-performance time series database

Do you think we are missing an alternative of comment or a related project?
Popular Comparisons
README
comment
Golang package for use comments in JSON config files
Motivation
json config file: config.json
{
"name": "example",
"address": "192.168.0.1",
"active": true
}
How we can change address?
Create a new file config2.json
or fix in the current one.
Both variants are not convenient.
What is proposed
Introduce end-line comment. For shielding use the symbol #.
new json-config file with comments config.cjson
{
"name": "example",
# "address": "192.168.0.1", - this line is commented
"address": "192.168.0.2", # New address!
"active": true
}
Easier and convenient than previous both variants.
For parse this file first use the function comment.Trim(data)
.
We obtain the following:
{
"name": "example",
"address": "192.168.0.2",
"active": true
}
Next, we use standard parser json.Unmarshal
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"github.com/toelsiba/comment"
)
type Config struct {
Name string `json:"name"`
Address string `json:"address"`
Active bool `json:"active"`
}
func main() {
data, err := ioutil.ReadFile("config.cjson")
if err != nil {
log.Fatal(err)
}
data = comment.Trim(data)
fmt.Println(string(data))
var config Config
err = json.Unmarshal(data, &config)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", config)
}
Or more short variant:
func main() {
var c Config
err := comment.ReadConfig("config.cjson", &c)
if err != nil {
log.Fatal(err)
}
fmt.Println(c)
}
If you need have symbol # in line - used doublet ##.