does not implement
Go Programming Language
Severity: MinorWhat it means
It ends a cannot use message, as in T does not implement I (missing method M).
Go's compiler docs: a value of type T is used as an interface, but T doesn't implement a method of the expected interface.
The part in brackets gives the reason: missing method M, wrong type for method M with have and want lines, method M has pointer receiver, or unexported method M.
Affected Models
- The Go compiler (go build, go run, go test)
How to Fix It
-
(missing method M)? Add it, with exactly the name and signature the interface asks for.
-
(wrong type for method M)? Compare the have and want lines, parameters and results, and make yours match want.
-
(method M has pointer receiver)? The method is declared on *T, so only a pointer implements the interface. Pass &v instead of v, or declare the method on T.
-
Check it where the type is declared: var _ io.Reader = (*T)(nil). Effective Go uses this line to make the compiler check the interface there.