Skip to content

Conversation

@maniak89
Copy link

I ran into a problem where I don't know the type myself - I get reflect.Value and call Interface(), which returns the type any(Struct{}), but then passing a pointer to a temporary variable storing the result of Interface() to defaults.SetDefaults leads to a panic (panic: reflect: call of reflect.Value.NumField on interface Value).

switch dst.Type().Kind() {
      case reflect.Struct:
        val := dst.Interface()
        defaults.SetDefaults(&val) // <- panic
        dst.Set(reflect.ValueOf(val))

        return val, nil
...

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

Successfully merging this pull request may close these issues.

1 participant