Skip to content

Counterintuitive handling of blank YAML properties with default values #89

@muety

Description

@muety

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions