Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config replace by env has bug when key contain dot #155

Open
careyyoung opened this issue May 10, 2024 · 0 comments
Open

config replace by env has bug when key contain dot #155

careyyoung opened this issue May 10, 2024 · 0 comments

Comments

@careyyoung
Copy link

Describe the bug
依赖版本:
github.com/rookie-ninja/rk-boot/v2 v2.2.22
github.com/rookie-ninja/rk-cache/redis v1.2.17
github.com/rookie-ninja/rk-db/mongodb v1.2.18
github.com/rookie-ninja/rk-db/redis v1.2.18
github.com/rookie-ninja/rk-entry/v2 v2.2.22
github.com/rookie-ninja/rk-gin/v2 v2.2.23
现象:

  1. 使用了配置文件:
  2. 获取配置:rkentry.GlobalAppCtx.GetConfigEntry("config").GetBool("key1.enable")
  3. 如果使用环境变量:key1_enable,覆盖不了配置文件中的值,
  4. 需要使用key1.enable,才能覆盖
  5. 应该是:github.com\rookie-ninja\rk-entry\v2@v2.2.22\entry\config_entry.go
    该行:entry.Viper.AutomaticEnv() 前 缺少调用:entry.Viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))

期望结果:
使用环境变量:key1_enable,可以覆盖配置文件中的值

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant