📝 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应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名

Overview

Config

GitHub go.mod Go version Codacy Badge GoDoc Build Status Actions Status Coverage Status Go Report Card

Golang's application config manage tool library.

中文说明

Features

  • Support multi format: JSON(default), INI, YAML, TOML, HCL, ENV, Flags
    • JSON content support comments. will auto clear comments
    • Other drivers are used on demand, not used will not be loaded into the application.
      • Possibility to add custom driver for your specific format
  • Support multi-file and multi-data loading
  • Support loading configuration from os ENV
  • Support for loading configuration data from remote URLs
  • Support for setting configuration data from command line arguments(flags)
  • Support data overlay and merge, automatically load by key when loading multiple copies of data
  • Support for binding all or part of the configuration data to the structure
  • Support get sub value by path, like map.key arr.2
  • Support parse ENV name and allow with default value. like envKey: ${SHELL|/bin/bash} -> envKey: /bin/zsh
  • Generic api Get Int Uint Int64 Float String Bool Ints IntMap Strings StringMap ...
  • Complete unit test(code coverage > 95%)

Provide a sub-package dotenv that supports importing data from files (eg .env) to ENV

Only use INI

If you just want to use INI for simple config management, recommended use gookit/ini

GoDoc

Usage

Here using the yaml format as an example(testdata/yml_other.yml):

name: app2
debug: false
baseKey: value2
shell: ${SHELL}
envKey1: ${NotExist|defValue}

map1:
    key: val2
    key2: val20

arr1:
    - val1
    - val21

Load data

examples code please see _examples/yaml.go:

package main

import (
    "github.com/gookit/config/v2"
    "github.com/gookit/config/v2/yaml"
)

// go run ./examples/yaml.go
func main() {
	config.WithOptions(config.ParseEnv)
	
	// add driver for support yaml content
	config.AddDriver(yaml.Driver)
	// config.SetDecoder(config.Yaml, yaml.Decoder)

	err := config.LoadFiles("testdata/yml_base.yml")
	if err != nil {
		panic(err)
	}

	// load more files
	err = config.LoadFiles("testdata/yml_other.yml")
	// can also load multi at once
	// err := config.LoadFiles("testdata/yml_base.yml", "testdata/yml_other.yml")
	if err != nil {
		panic(err)
	}
	
	// fmt.Printf("config data: \n %#v\n", config.Data())
}

Map Data To Structure

Note: The default binding mapping tag of a structure is mapstructure, which can be changed by setting Options.TagName

user := struct {
    Age  int
    Kye  string
    UserName  string `mapstructure:"user_name"`
    Tags []int
}{}
err = config.BindStruct("user", &user)

fmt.Println(user.UserName) // inhere

Direct Read data

  • Get integer
age := config.Int("age")
fmt.Print(age) // 100
  • Get bool
val := config.Bool("debug")
fmt.Print(val) // true
  • Get string
name := config.String("name")
fmt.Print(name) // inhere
  • Get strings(slice)
arr1 := config.Strings("arr1")
fmt.Printf("%#v", arr1) // []string{"val1", "val21"}
  • Get string map
val := config.StringMap("map1")
fmt.Printf("%#v",val) // map[string]string{"key":"val2", "key2":"val20"}
  • Value contains ENV var
value := config.String("shell")
fmt.Print(value) // "/bin/zsh"
  • Get value by key path
// from array
value := config.String("arr1.0")
fmt.Print(value) // "val1"

// from map
value := config.String("map1.key")
fmt.Print(value) // "val2"
  • Setting new value
// set value
config.Set("name", "new name")
name = config.String("name")
fmt.Print(name) // "new name"

Load from flags

Support simple flags parameter parsing, loading

// flags like: --name inhere --env dev --age 99 --debug

// load flag info
keys := []string{"name", "env", "age:int" "debug:bool"}
err := config.LoadFlags(keys)

// read
config.String("name") // "inhere"
config.String("env") // "dev"
config.Int("age") // 99
config.Bool("debug") // true

Load from ENV

// os env: APP_NAME=config APP_DEBUG=true
// load ENV info
config.LoadOSEnv([]string{"APP_NAME", "APP_DEBUG"}, true)

// read
config.Bool("app_debug") // true
config.String("app_name") // "config"

New Config Instance

You can create custom config instance

// create new instance, will auto register JSON driver
myConf := config.New("my-conf")

// create empty instance
myConf := config.NewEmpty("my-conf")

// create and with some options
myConf := config.NewWithOptions("my-conf", config.ParseEnv, config.ReadOnly)

Available Options

// Options config options
type Options struct {
	// parse env value. like: "${EnvName}" "${EnvName|default}"
	ParseEnv bool
	// config is readonly. default is False
	Readonly bool
	// enable config data cache. default is False
	EnableCache bool
	// parse key, allow find value by key path. default is True eg: 'key.sub' will find `map[key]sub`
	ParseKey bool
	// tag name for binding data to struct
	TagName string
	// the delimiter char for split key, when `FindByPath=true`. default is '.'
	Delimiter byte
	// default write format. default is JSON
	DumpFormat string
	// default input format. default is JSON
	ReadFormat string
}

API Methods Refer

Load Config

  • LoadOSEnv(keys []string) Load from os ENV
  • LoadData(dataSource ...interface{}) (err error) Load from struts or maps
  • LoadFlags(keys []string) (err error) Load from CLI flags
  • LoadExists(sourceFiles ...string) (err error)
  • LoadFiles(sourceFiles ...string) (err error)
  • LoadRemote(format, url string) (err error)
  • LoadSources(format string, src []byte, more ...[]byte) (err error)
  • LoadStrings(format string, str string, more ...string) (err error)

Getting Values

  • Bool(key string, defVal ...bool) bool
  • Int(key string, defVal ...int) int
  • Uint(key string, defVal ...uint) uint
  • Int64(key string, defVal ...int64) int64
  • Ints(key string) (arr []int)
  • IntMap(key string) (mp map[string]int)
  • Float(key string, defVal ...float64) float64
  • String(key string, defVal ...string) string
  • Strings(key string) (arr []string)
  • StringMap(key string) (mp map[string]string)
  • Get(key string, findByPath ...bool) (value interface{})

Setting Values

  • Set(key string, val interface{}, setByPath ...bool) (err error)

Useful Methods

  • Getenv(name string, defVal ...string) (val string)
  • AddDriver(driver Driver)
  • Data() map[string]interface{}
  • SetData(data map[string]interface{}) set data to override the Config.Data
  • Exists(key string, findByPath ...bool) bool
  • DumpTo(out io.Writer, format string) (n int64, err error)
  • BindStruct(key string, dst interface{}) error

Run Tests

go test -cover
// contains all sub-folder
go test -cover ./...

Gookit packages

  • gookit/ini Go config management, use INI files
  • gookit/rux Simple and fast request router for golang HTTP
  • gookit/gcli build CLI application, tool library, running CLI commands
  • gookit/event Lightweight event manager and dispatcher implements by Go
  • gookit/cache Generic cache use and cache manager for golang. support File, Memory, Redis, Memcached.
  • gookit/config Go config management. support JSON, YAML, TOML, INI, HCL, ENV and Flags
  • gookit/color A command-line color library with true color support, universal API methods and Windows support
  • gookit/filter Provide filtering, sanitizing, and conversion of golang data
  • gookit/validate Use for data validation and filtering. support Map, Struct, Form data
  • gookit/goutil Some utils for the Go: string, array/slice, map, format, cli, env, filesystem, test and more
  • More please see https://github.com/gookit

See also

License

MIT

Issues
  • How to parse ini to struct if data within [brackets] is variable?

    How to parse ini to struct if data within [brackets] is variable?

    Hello, I was wondering how I might go about parsing to a struct a file like below:

    [variablename1]
    type = 
    client_id = 
    client_secret = 
    scope = 
    token = 
    
    

    [variablename1] will always be unique as it is a name assigned at the time of creation of the ini, the rest of the fields will always have the same key name.

    I was going to have:

    type Settings struct {
    	Remote struct {
    		Type         string `json:"type"`
    		ClientId     string `json:"client_id"`
    		ClientSecret string `json:"client_secret"`
    		Scope        int    `json:"scope"`
    		Token        int    `json:"token"`
    	} `json:"???"` // --- This will always be different
    }
    
    

    Is there a way to deal with this? Thanks, -MH

    question 
    opened by MostHated 8
  • 文件名后缀作为判断依据的问题

    文件名后缀作为判断依据的问题

    对于一些工具的配置文件,格式虽然可能是ini,yaml或者json 但是为了区分这些文件的作用,可能不再是ini,yaml这样的后缀, 而是会以rules,system这样的后缀结尾, 而我看你的parseSourceCode()中会检查这样的后缀,作为文件格式的判断依据 但是对于上述描述到的文件,就会被认定为不合法的文件格式,

    对于这样的情况能否给个方法,可以让我直接指定文件格式,从而解决这样的问题呢?

    enhancement 
    opened by yuechao-zhao 6
  • mapstructure.DecoderConfig.Squash support config in Options()

    mapstructure.DecoderConfig.Squash support config in Options()

    cfgLoader := config.NewWithOptions("", func(options *config.Options) {
        options.TagName = "json"
        options.Squash  = true
    })
    
    type Test1 struct {
        B int `json:"b"`
    }
    type Test2 struct {
        Test1
        C int `json:"c"`
    }
    cfg := &Test2{}
    
    cfgLoader.BindStruct("", cfg)
    
    mapConf := &mapstructure.DecoderConfig{
    		Metadata: nil,
    		Result:   dst,
    		TagName:  c.opts.TagName,
                    Squash :  c.opts.Squash ,                   // support embedded structs
    		// will auto convert string to int/uint
    		WeaklyTypedInput: true,
    	}
    
    
    enhancement 
    opened by RelicOfTesla 5
  • Got panic when load json then yaml to overwrite a key in json

    Got panic when load json then yaml to overwrite a key in json

    config/test0.json:

    {
        "lang": {
            "allowed": {
                "en": "ddd"
            }
        }
    }
    

    config/test1.yaml:

    lang:
      allowed:
        en: "666"
    

    run the following code:

    package main
    
    import (
    	"fmt"
    	"os"
    	"path/filepath"
    
    	"github.com/gookit/config/v2"
    	"github.com/gookit/config/v2/yaml"
    )
    
    func main() {
    	config.AddDriver(yaml.Driver)
    	config.Default().Options().TagName = "json"
    
    	filepath.Walk("config", func(path string, info os.FileInfo, err error) error {
    		if err != nil {
    			return err
    		}
    
    		if info.IsDir() {
    			return nil
    		}
    
    		fmt.Printf("loading %s...\n", path)
    		return config.LoadFiles(path)
    	})
    }
    

    got this panic:

    loading config/test0.json...
    loading config/test1.yaml...
    panic: reflect.Value.MapIndex: value of type interface {} is not assignable to type string
    

    if reverse the loading order, i.e. load test1.yaml first then test0.json, it works

    bug help wanted 
    opened by guiguan 5
  • Support Pretty Print?

    Support Pretty Print?

    Would be nice to have support for pretty print out-of-the-box like Viper. Currently: config.Set()

    {"parent":{"child":{"grandChild":"Test Val"}}}
    

    Expecting:

    {
      "parent": {
        "child": {
          "grandChild": "Test Val"
        }
      }
    }
    

    Is this posible? Or any work-around for this?

    question 
    opened by KiddoV 4
  • ini: invalid data to encode as ini

    ini: invalid data to encode as ini

    解析ini文件时候,使用了ini.Driver 但在把data写会文件时候,发生了"ini: invalid data to encode as ini" 使用(* config)DumpTo() method 查看代码发现ini的Encode代码是这么写的:

    func Encode(v interface{}, defSection ...string) (out []byte, err error) {
        switch vd := v.(type) {
        case map[string]interface{}: // from full mode
            return EncodeFull(vd, defSection...)
        case map[string]map[string]string: // from simple mode
            return EncodeSimple(vd, defSection...)
        default:
            err = errors.New("ini: invalid data to encode as ini")
        }
        return
    }
    

    但是在func (c *Config) DumpTo(out io.Writer, format string) (n int64, err error)却是这么调用的

        // encode data to string
        encoded, err := encoder(&c.data)
        if err != nil {
            return
        }
    

    取的是c.data的地址(&c.data),所以type永远匹配不上 所以这里或许是个bug,还是说,这里我的用法有问题,我的代码如下:

    func main() {
        r := config.New("yyyy")
        r.WithOptions(config.ParseEnv)
    
        r.AddDriver(ini.Driver)
    
        err := r.LoadFiles("yyyy.ini")
        if err != nil {
            panic(err)
        }
    
        fmt.Printf("config data: \n %#v\n", r.Data())
    
        f, e := os.OpenFile("xxxx.ini", os.O_RDWR|os.O_CREATE, 0666)
        if e != nil {
            fmt.Println(e)
            return
        }
        defer f.Close()
    
        n, e := r.DumpTo(f, config.Ini)
        fmt.Println(n, e)
    }
    
    bug 
    opened by yuechao-zhao 3
  • Add http://  Support

    Add http:// Support

    	"address": [
    		"192.168.1.XXX:2379",
    		"192.168.1.XXX:2379",
    		"192.168.1.XXX:2379"
    	]
    

    is OK, but "address": [ "http://192.168.1.XXX:2379", "http://192.168.1.XXX:2379", "http://192.168.1.XXX:2379" ] is panic. panic: ReadString: invalid control character found: 10, error found in #10 byte of ...|79" Strings containing “http://” are very common, Don't be confused with comments。 Tanks.

    bug 
    opened by zhangjinming 3
  • config does not use ParseEnv option on nested keys.

    config does not use ParseEnv option on nested keys.

    System (please complete the following information):

    • OS: linux
    • GO Version: 1.16.4
    • Pkg Version: 2.0.23

    Describe the bug

    config does not use ParseEnv option on nested keys.

    To Reproduce

    import (
        config "github.com/gookit/config/v2"
    )
    
    func BugReport() {
    	jsonStr := `{
        "envKey": "${SHELL}",
        "map1": {
            "key1": "${SHELL}"
        }
    }`
    
    	config.AddDriver(config.JSONDriver)
    	config.WithOptions(config.ParseEnv)
    	_ = config.LoadStrings(config.JSON, jsonStr)
    	// works ok /bin/my-shell
    	fmt.Println(config.String("envKey", ""))
    	map1 := config.StringMap("map1")
    	// "${SHELL}"
    	fmt.Println("get map", map1["key1"])
    }
    
    

    Expected behavior should give me /bin/bash

    fmt.Println("get map", map1["key1"])
    
    enhancement 
    opened by beckend 2
  • Regression in yml file support introduced

    Regression in yml file support introduced

    System:

    • OS: linux
    • GO Version: 1.15.6
    • Pkg Version: 2.0.19

    Describe the bug

    This change (see #30) introduced a regression in the supported file types. Before that, the function LoadFiles supported yaml and .yml extensions after loading the yaml.Driver driver.

    To Reproduce

    AddDriver(yaml.Driver)
    ...
    LoadFiles("file.yml")
    ..
    

    Expected behavior

    I expect that once the yaml.Driver is loaded, both .yaml and .yml files are supported.

    bug help wanted 
    opened by vthiery 2
  • Bump github.com/imdario/mergo from 0.3.10 to 0.3.11

    Bump github.com/imdario/mergo from 0.3.10 to 0.3.11

    Bumps github.com/imdario/mergo from 0.3.10 to 0.3.11.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in the .github/dependabot.yml file in this repo:

    • Update frequency
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)
    dependencies 
    opened by dependabot-preview[bot] 2
  • build(deps): bump github.com/BurntSushi/toml from 1.1.0 to 1.2.0

    build(deps): bump github.com/BurntSushi/toml from 1.1.0 to 1.2.0

    Bumps github.com/BurntSushi/toml from 1.1.0 to 1.2.0.

    Release notes

    Sourced from github.com/BurntSushi/toml's releases.

    Release v1.2.0

    This release adds a few additional features:

    • Support encoding and decoding json.Number, making interoperability with JSON when using json.Encoder.UseNumber() easier.

    • Support time.Duration string format; an integer will be interpreted as nanoseconds (like before), but a string like "5h" will be parsed. On encoding the string format is used.

    • The omitempty struct tag now also works for structs with all zero values, for example an empty time.Time. A struct is considered "empty" when all fields (exported and private) are the zero value.

    • Allow using interface{} (or any) as the map key when decoding.

    And some fixes:

    • Fix encoding.TextUnmarshaler not working for map values.

    • Make encoding.TextUnmarshaler and toml.Unmarshaler work if MarshalText() or MarshalTOML() have a pointer receiver.

    • Error out on nil returns from MarshalTOML/MarshalText; before they would get encoded as invalid TOML (keyname =).

    • Fix a panic where it would try to encode array = [{}, 0] as:

      [[array]]
      [[array]]
      

      Which isn't valid as 0 isn't a table.

    • Some better error reporting for some errors.

    Commits
    • 2e74712 Simplify test case
    • e2f6fa2 Allow using interface{} as map keys when decoding
    • f0ccf71 Merge pull request #358 from kkHAIKE/encode_MarshalText_fix
    • c03a31c Small stylistic updates
    • 6805a3d add test for embed field
    • 0ae83fe replace some Interface() check when encode private embed struct
    • eaf0d98 add test
    • d138d7a change eindirect behave match with indirect from decode
    • 0a9f2b0 Don't panic encoding arrays where the first item is a table, but others aren't
    • 28ff18d Merge pull request #356 from BurntSushi/empty
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies go 
    opened by dependabot[bot] 1
  • 并发调用 Structure,存在获取不到数据的情况

    并发调用 Structure,存在获取不到数据的情况

    System (please complete the following information):

    • OS: linux
    • GO Version: 1.18
    • Pkg Version: 2.1.2

    Describe the bug

    func (c *Config) Structure(key string, dst interface{}) error 该方法在并发调用时,dst 会存在获取失败的情况

    To Reproduce

    func (c *Config) Structure(key string, dst interface{}) error
    

    Expected behavior

    func (c *Config) Structure(key string, dst interface{}) error 该方法在并发调用时,dst 会存在获取失败的情况

    bindConf.Result = dst // set result struct ptr

    在并发调用时,bindConf.Result 的值存在被覆盖的情况

    bug 
    opened by tiandh987 0
  • ``Config.Set()`` is Not Override New Value if Value is Not The Same Type

    ``Config.Set()`` is Not Override New Value if Value is Not The Same Type

    The config.Set() should override the value even though the old value is not the same type of the new one. EX:

    {
      "parent": {
        "child": "Test Var"  
      }
    }
    

    After config.Set("parent.child.grandChild", "New Val") the object should be:

    {
      "parent": {
        "child": {
          "grandChild": "New Val"  
        } 
      }
    }
    

    As for now, it does not change anything or not even throw any error. I think it is because parent.child value was a string so it doesn't allow me to add a new struct ({grandChild: "New Val"}) to it.

    Any idea how to fix it?

    question 
    opened by KiddoV 0
Releases(v2.1.2)
  • v2.1.2(Jun 1, 2022)

    Change Log

    • fix: should clear last error after read by config.Error(). close: #76 https://github.com/gookit/config/commit/3be21082b26909d3aef190859f6c77b5785b85e3

    Full Changelog: https://github.com/gookit/config/compare/v2.1.1...v2.1.2

    Source code(tar.gz)
    Source code(zip)
  • v2.1.1(May 28, 2022)

    Change Log

    Refactor

    • refactor: refactoring the config drivers build logic https://github.com/gookit/config/commit/4dd95c81c023e6087f306ef7bcb4f8bc779e33e0

    Update

    • update: update gh action script and readme https://github.com/gookit/config/commit/a4ca4c099339503e4a5a029adfbdb5dbfd3c2c0b
    • chore: update readme, update action script https://github.com/gookit/config/commit/2dddf2b2c806ac51c30409e72c33f1dcebf8ad4b
    • up: update readme and release action https://github.com/gookit/config/commit/9d268b91bcd58563e7c286931e7a8aeaf02bd686
    • up: add changelog gen config file https://github.com/gookit/config/commit/59e1fb2ee7d56a650976f7befafb6a2800f98202
    • chore: update the action for check go code style https://github.com/gookit/config/commit/e29f6afd1e6487860e389a6c5ac06f571a6e42a3

    Other

    • build(deps): bump github.com/mitchellh/mapstructure from 1.4.3 to 1.5.0 https://github.com/gookit/config/commit/2c73e83457ef580e7a657029981ff0ee39570058
    • build(deps): bump github.com/hashicorp/hcl/v2 from 2.11.1 to 2.12.0 https://github.com/gookit/config/commit/5511ab38d96152ec27923a9455c17541d46de675
    • build(deps): bump github.com/gookit/goutil from 0.5.0 to 0.5.1 https://github.com/gookit/config/commit/c5fa74d11f1629380f34f66098596b3162815c31
    • build(deps): bump github.com/gookit/goutil from 0.5.1 to 0.5.2 https://github.com/gookit/config/commit/72e1e655c08055faaa5d153f07867c0b986fa536
    • chore: fix some code check error by staticcheck https://github.com/gookit/config/commit/02b6ba59f83353058b8efab75965fa0633b24e44
    • build(deps): bump github.com/imdario/mergo from 0.3.12 to 0.3.13 https://github.com/gookit/config/commit/62659df2fb043b09c4e9460d9ae327183b0554df
    • build(deps): bump gopkg.in/yaml.v3 from 3.0.0 to 3.0.1 https://github.com/gookit/config/commit/e0ab4c529b1bbe3cb9a8308d090b7c0719984b72
    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Apr 16, 2022)

    Change Log

    Feature

    • feat: add new method: MapOnExists - mapping data to the dst struct only on key exists https://github.com/gookit/config/commit/f1ab0eb084341b4cf38488e28d9557908e20768f
    • feat: support listen and fire events on config data changed. close: #61 https://github.com/gookit/config/commit/d9f66ad78ae8a94fa4181eed35d176ef4df95b9c

    Fixed

    • fix: fix unit test error https://github.com/gookit/config/commit/42daae9716c2943d49db0bddcf0cd5a894c93949
    • test: fix the action test fail https://github.com/gookit/config/commit/086e6228aff8830a7df6858881217765ca2ba38f

    Other

    • style: update readme and action scripts https://github.com/gookit/config/commit/79df2b36f3dda1859e5402d6592cb9766de0c28c
    • doc: update options code https://github.com/gookit/config/commit/c5f64c326ed769d7fb7e3ee87f92d36547088b1f
    • chore(deps): update dep versions https://github.com/gookit/config/commit/3e4401908c3635e1d070197f683261b655aab95b
    • chore(action): update dependabot config https://github.com/gookit/config/commit/812b24b4d1ca5d7a3eaa09dbd902fd95389ede6e
    • build(deps): bump actions/checkout from 2 to 3 https://github.com/gookit/config/commit/126d8f9784815b70f23660717fbb37f1056e83b1
    • build(deps): bump actions/setup-go from 2 to 3 https://github.com/gookit/config/commit/49f0d171844f8662c7f1c98169b582c005dac1ea
    • build(deps): bump github.com/BurntSushi/toml from 0.3.1 to 1.1.0 https://github.com/gookit/config/commit/d7a3f03b68784f4701bf3ebfa7b309eacd2cdc7a
    • build(deps): bump github.com/json-iterator/go from 1.1.11 to 1.1.12 https://github.com/gookit/config/commit/bed522516ea56a677e9c97faec157812615d5803
    • build(deps): bump github.com/hashicorp/hcl/v2 from 2.10.1 to 2.11.1 https://github.com/gookit/config/commit/63c8e25b0d047845ffa46b92eaec134f1893f2ae
    • chore: add test on go1.18, will not test on go < 1.15 https://github.com/gookit/config/commit/086f1f42275e05dcf23b77b5639a3d35361ca063
    • pref: add lock on call SetData https://github.com/gookit/config/commit/35f7ececd6287f2ff46f35d6123081150b80ead0
    • pref: add more unit tests, update readme https://github.com/gookit/config/commit/fe691833dc4f89c97721553fdf5099fbfbc82319
    Source code(tar.gz)
    Source code(zip)
  • v2.0.27(Oct 13, 2021)

  • v2.0.26(Oct 5, 2021)

  • v2.0.25(Jul 29, 2021)

  • v2.0.24(May 19, 2021)

  • v2.0.23(Apr 7, 2021)

  • v2.0.22(Mar 16, 2021)

  • v2.0.21(Feb 10, 2021)

  • v2.0.20(Feb 5, 2021)

  • v2.0.19(Feb 5, 2021)

  • v2.0.18(Dec 9, 2020)

  • v2.0.17(Aug 6, 2020)

  • v2.0.16(Jul 16, 2020)

  • v2.0.15(Jul 13, 2020)

  • v2.0.14(Jul 10, 2020)

  • v2.0.12(Aug 24, 2019)

  • v2.0.11(Aug 4, 2019)

    • parse ENV use goutil.envutil instead
    • update: complete config data bind to struct
    • update some logic for dotenv pacakge
    • update travis ci srcpit for report cover
    • update readme
    Source code(tar.gz)
    Source code(zip)
  • v2.0.10(Aug 3, 2019)

  • v2.0.7(Jun 28, 2019)

  • v2.0.4(May 23, 2019)

  • v2.0.3(Mar 9, 2019)

  • v2.0.2(Jan 19, 2019)

  • v2.0.1(Jan 14, 2019)

  • v2.0.0(Jan 13, 2019)

  • v1.1.0(Jan 13, 2019)

  • v1.0.12(Jan 12, 2019)

  • v1.0.11(Nov 23, 2018)

  • v1.0.10(Sep 15, 2018)

Owner
Gookit
Useful libs for the Go(router, DI, log, config, cache, event, validate, filter, CLI, i18n, respond-data, view-render)
Gookit
Library providing routines to merge and validate JSON, YAML and/or TOML files

CONFLATE Library providing routines to merge and validate JSON, YAML, TOML files and/or structs (godoc) Typical use case: Make your application config

Andy 25 May 5, 2022
Package ini provides INI file read and write functionality in Go.

INI Package ini provides INI file read and write functionality in Go. Features Load from multiple data sources(file, []byte, io.Reader and io.ReadClos

INI 3k Aug 7, 2022
Tmpl - A tool to apply variables from cli, env, JSON/TOML/YAML files to templates

tmpl allows to apply variables from JSON/TOML/YAML files, environment variables or CLI arguments to template files using Golang text/template and functions from the Sprig project.

krako 1 May 30, 2022
Generic templating tool with support of JSON, YAML and TOML data

gotempl Small binary used to generate files from Go Templates and data files. The following formats are supported: JSON YAML TOML Usage usage: gotempl

Link Society 7 Jun 15, 2022
Golang Configuration tool that support YAML, JSON, TOML, Shell Environment

Configor Golang Configuration tool that support YAML, JSON, TOML, Shell Environment (Supports Go 1.10+) Usage package main import ( "fmt" "github.c

Jinzhu 1.5k Aug 11, 2022
Go-config - Config parser for go that supports environment vars and multiple yaml files

go-multiconfig This package is able to parse yaml config files. It supports gett

Dimitris Tassopoulos 1 Jun 23, 2022
⚙️ Dead Simple Config Management, load and persist config without having to think about where and how.

Configo Dead Simple Config Management, load and persist config without having to think about where and how. Install go get github.com/UltiRequiem/conf

Eliaz Bobadilla 8 Apr 6, 2022
Library for setting values to structs' fields from env, flags, files or default tag

Configuration is a library for injecting values recursively into structs - a convenient way of setting up a configuration object. Available features:

Bogdan Daragan 73 Jul 25, 2022
A Go (golang) environment loader (which loads env vars from a .env file)

A Go (golang) environment loader (which loads env vars from a .env file)

Bendt Indonesia 0 Feb 8, 2022
Quick and easy way to load config files based on a simple set of rules.

config Quick and easy way to load config files based on a simple set of rules. Project inspired by https://github.com/lorenwest/node-config Important

Tarcisio Gruppi 1 Apr 9, 2021
A simple INI file parser and builder.

ini A simple INI file parser and builder. What Read INI files, or build them section by section. Datatypes are kept very simple. The main fuctions are

Grimdork.net 1 Nov 20, 2021
HCL is the HashiCorp configuration language.

HCL HCL is a toolkit for creating structured configuration languages that are both human- and machine-friendly, for use with command-line tools. Altho

HashiCorp 4.2k Aug 3, 2022
create a bootable disk image from Docker image or a yaml config

docker2boot docker2boot creates a bootable disk from either a Docker image or a config yaml file Features status dns Y cloud-init Y network Y ssh TODO

Bin Chen 7 Jul 19, 2022
Golang config.yaml loader

Description goconfig is a configuration library designed using the following pri

null 2 May 31, 2022
A golang package for parsing ini-style configuration files

Mini Mini is a simple ini configuration file parser. The ini syntax supported includes: The standard name=value Comments on new lines starting with #

Stephen Asbury 31 Jul 7, 2022
ini parser for golang

INI Parser & Write Library ini parser and write library for Golang,easy-use,fast Features Can be read by []byte Can be read by file Supports file moni

levene 9 Apr 6, 2022
Tinyini - Bare-bones Go library for reading INI-like configuration files

tinyini tinyini is a minimalistic library for parsing INI-like configuration files. example configuration file globalkey = globalvalue [section] key

null 0 Jan 10, 2022
INI Loader written in Go

go-ini INI Loader written in Go Single threaded & simple Examples Read all params func (app MyApp) onParam(name string, value string) bool { app.c

Denis 1 Feb 11, 2022
Go-yaml - Yaml parsing Toolkit For Golang

go-yaml 介绍 gopkg.in/yaml.v3 已经是个非常好用的包,但是在实际开发中总有类型转换带来的麻烦,go-yaml只是在它的基础上,简单的一层

xiaowu 4 Jan 13, 2022