Skip to content

Commit

Permalink
home: imp code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizzick committed Aug 29, 2023
1 parent 5fa09a9 commit ef40d07
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions internal/home/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -1568,17 +1568,10 @@ func moveField[T any](fromObj, newConf yobj, key, newKey string) (err error) {

if newVal == nil {
newConf[newKey] = nil

return nil
}

v, ok := newVal.(T)
if !ok {
return fmt.Errorf("invalid type of %s: %T", key, newVal)
} else {
newConf[newKey] = *newVal
}

newConf[newKey] = v

return nil
}

Expand All @@ -1590,7 +1583,7 @@ func moveFieldValue[T any](fromObj, newConf yobj, key string) (err error) {

// fieldValue returns the value of type T for key in confObj object. Returns
// nil for fields with nil values.
func fieldValue[T any](confObj yobj, key string) (ok bool, field any, err error) {
func fieldValue[T any](confObj yobj, key string) (ok bool, field *T, err error) {
fieldVal, ok := confObj[key]
if !ok {
return false, new(T), nil
Expand All @@ -1605,7 +1598,7 @@ func fieldValue[T any](confObj yobj, key string) (ok bool, field any, err error)
return false, nil, fmt.Errorf("unexpected type of %s: %T", key, fieldVal)
}

return true, f, nil
return true, &f, nil
}

// coalesceError returns the first non-nil error. It is named after function
Expand Down

0 comments on commit ef40d07

Please sign in to comment.