Open
Description
What version of Go are you using (go version
)?
$ go version go1.15.6
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env
)?
n/a
What did you do?
This code:
type FooError interface {
Something() int
Error() string
}
err := someCall();
err.(*FooError)
Complains:
impossible type assertion:
*FooError does not implement error (missing Error method)
The issue is that you need to write err.(FooError)
.
What did you expect to see?
It'd be much more helpful if it'd call out that FooError
does implement error, so the problem is the added pointer indirection.
This mistake is likely because usually the concrete struct types implement error via the pointer reference, so if you change code from the concrete struct error to an interface type, you're likely to miss a *
in there.
What did you see instead?
The error message above.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Triage Backlog