Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V8035. Type assertion is always...
menu mobile close menu
Additional information
toggle menu Contents

V8035. Type assertion is always false. Check interfaces used in the type assertion, as they contain methods with incompatible signatures.

Aug 06 2026

The analyzer has detected a type assertion that can never succeed because both interfaces contain a method with the same name but different signatures.

The example:

type Validator interface {
  Validate() error
}

type ContextValidator interface {
  Validate(map[string]string) error
}

func check(v Validator) {
  ....
  if cv, ok = v.(ContextValidator); ok {
    ....
  }
  ....
}

In the example, the v.(ContextValidator) assertion cannot be true because the Validate method has different signatures in the Validator and ContextValidator interfaces.

Such a type assertion would only make sense if the signatures of the Validate method are identical:

type Validator interface {
  Validate() error
}

type ContextValidator interface {
  Validate() error
}