fix: default config override (#719)

This commit is contained in:
Nemanja Milićević
2024-12-17 03:53:05 +01:00
committed by GitHub
parent 2186c12645
commit 023234486a
2 changed files with 3 additions and 3 deletions
+3 -1
View File
@@ -387,7 +387,9 @@ func (c *Config) rel(path string) string {
// WithArgs returns a new config with the given arguments added to the configuration.
func (c *Config) WithArgs(args map[string]TomlInfo) {
for _, value := range args {
if value.Value != nil && *value.Value != unsetDefault {
// Ignore values that match the default configuration.
// This ensures user-specified configurations are not overwritten by default values.
if value.Value != nil && *value.Value != value.fieldValue {
v := reflect.ValueOf(c)
setValue2Struct(v, value.fieldPath, *value.Value)
}
-2
View File
@@ -4,8 +4,6 @@ import (
"flag"
)
const unsetDefault = "DEFAULT"
// ParseConfigFlag parse toml information for flag
func ParseConfigFlag(f *flag.FlagSet) map[string]TomlInfo {
c := defaultConfig()