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

Add an ability to do not fail Decode function if no 'default' value specified in the 'properties' tag #33

Open
alxeg opened this issue Jul 16, 2018 · 0 comments

Comments

@alxeg
Copy link

alxeg commented Jul 16, 2018

Currently the Decode function returns an error if the tag does not contain 'default' and the key does not exist in the properties file.

Sometimes it's preferable to do not fail in this case but use the original field value of the structure passed to the Decode function, e.g by passing some specific key ('predefined') to the properties tag:

type Config struct {
	Field string `properties:"somefield,predefined"`
}

conf := &Config{
    Field: "Default value"
}

p := properties.MustLoadFiles([]string{
    "config.properties",
}, properties.UTF8, true)

err := p.Decode(conf)

if err == nil {
    fmt.Println(conf.Field)
}
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