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

Counterintuitive handling of blank YAML properties with default values #89

Open
muety opened this issue Dec 29, 2023 · 0 comments
Open

Comments

@muety
Copy link

muety commented Dec 29, 2023

Consider the following example:

config.go:

type MyConfig struct {
  FooBar `yaml:"foo_bar,omitempty" default:"baz"`
}

config.yaml:

foo_bar: 

With configor 1.2.1, the above config led to FooBar being set to an empty string, while with configor 1.2.2, FooBar will be set to the default value of "baz".

First of all, I think that this should have gotten mentioned somewhere, because it's kind of a breaking change in some cases.

Besides that, I think the new behavior is a bit counterintuitive. For my taste, you should be able to overwrite a property - even if it has a default value - by explicitly setting it in YAML. So for me it would make sense to (a) take default value if key is not specified in YAML, but (b) take whatever value from the YAML if key is specified there, even if blank.

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