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)
}
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: