You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
What did you do?
package main
import "fmt"
type S interface {
Resolve(string)
}
type impl struct{}
func (i *impl) Resolve(a interface{}) {
fmt.Println(a)
}
func main() {
fmt.Println("start")
x := S(&impl{})
x.Resolve("hi")
}
What did you expect to see?
Since the Resolve method in impl accepts interface{} it should be valid to pass it a string and it should be a valid implementation of the S interface
What did you see instead?
cannot convert &impl{} (type *impl) to type S:
*impl does not implement S (wrong type for Resolve method)
have Resolve(interface {})
want Resolve(string)
The text was updated successfully, but these errors were encountered:
Method signatures in Go must match exactly for a type to satisfy an interface. Having arguments that are assignable to / return values that are assignable from is not enough.
Closing as a dup of #30602, there is much more discussion there.
What version of Go are you using (
go version
)?Latest playground
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
Since the Resolve method in impl accepts
interface{}
it should be valid to pass it a string and it should be a valid implementation of theS
interfaceWhat did you see instead?
The text was updated successfully, but these errors were encountered: