Skip to content

Instantly share code, notes, and snippets.

@ghais
Created June 11, 2011 18:46
Show Gist options
  • Save ghais/1020833 to your computer and use it in GitHub Desktop.
Save ghais/1020833 to your computer and use it in GitHub Desktop.
example.go
package main
type Foo interface {
FooBar(other Foo)
}
func Bar(f Foo) {
f.FooBar(f)
}
type Baz struct {}
func (b *Baz) FooBar(other *Baz) {
}
func main() {
var b Baz
Bar(&b)
}
@ghais
Copy link
Author

ghais commented Jun 11, 2011

play.go:20: cannot use &b (type *Baz) as type Foo in function argument:
*Baz does not implement Foo (wrong type for FooBar method)
have FooBar(other *Baz)
want FooBar(other Foo)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment