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

Fix default value in slices #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

moycat
Copy link

@moycat moycat commented Jul 16, 2021

The default values are applied before the config is loaded. So the later loaded structs in the slice don't have default values.

configor/utils.go

Lines 375 to 391 in 1095c48

configor.processDefaults(config)
for _, file := range configFiles {
if configor.Config.Debug || configor.Config.Verbose {
fmt.Printf("Loading configurations from file '%v'...\n", file)
}
if err = processFile(config, file, configor.GetErrorOnUnmatchedKeys()); err != nil {
return err, true
}
}
configor.configModTimes = configModTimeMap
if prefix := configor.getENVPrefix(config); prefix == "-" {
err = configor.processTags(config)
} else {
err = configor.processTags(config, prefix)
}

Loading the default values after parsing config files and env should fix this.

Related to #67.

@hulucc
Copy link

hulucc commented Jul 26, 2021

This will not work, it break something else

@moycat
Copy link
Author

moycat commented Jul 26, 2021

This will not work, it break something else

What’s broken?

@hulucc
Copy link

hulucc commented Jul 26, 2021

This will not work, it break something else

What’s broken?

I don't remember but i tired to change like this locally, somethings else go wrong.

@moycat
Copy link
Author

moycat commented Jul 26, 2021

This will not work, it break something else

What’s broken?

I don't remember but i tired to change like this locally, somethings else go wrong.

Well, at least no tests fail. You can add a unit test when you remember it.

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

Successfully merging this pull request may close these issues.

None yet

2 participants