Skip to content

Commit

Permalink
Bug fix: In auto-reload mode, the configuration fails to revert to th…
Browse files Browse the repository at this point in the history
…e default value when a configuration item is removed from the file.
  • Loading branch information
fangyuan@lccomputing.com committed Apr 27, 2024
1 parent f7a0fc7 commit dd4b2fa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion configor.go
Expand Up @@ -85,7 +85,8 @@ func (configor *Configor) GetErrorOnUnmatchedKeys() bool {

// Load will unmarshal configurations to struct from files that you provide
func (configor *Configor) Load(config interface{}, files ...string) (err error) {
defaultValue := reflect.Indirect(reflect.ValueOf(config))
defaultValue := reflect.New(reflect.ValueOf(config).Elem().Type()).Elem()
defaultValue.Set(reflect.Indirect(reflect.ValueOf(config)))
if !defaultValue.CanAddr() {
return fmt.Errorf("Config %v should be addressable", config)
}
Expand Down

0 comments on commit dd4b2fa

Please sign in to comment.