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

Home Page:https://pkg.go.dev/github.com/gookit/config/v2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

config does not use ParseEnv option on nested keys.

beckend opened this issue · comments

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"])

@inhere you have to make a new release.

has been released, thanks :)