Skip to content

Instantly share code, notes, and snippets.

@codecakes
Created August 25, 2018 14:13
Show Gist options
  • Select an option

  • Save codecakes/c3ccdd96ea82f78635ebec8d25d2ed15 to your computer and use it in GitHub Desktop.

Select an option

Save codecakes/c3ccdd96ea82f78635ebec8d25d2ed15 to your computer and use it in GitHub Desktop.
if you are returning, an implementation type is needed
package main
import "fmt"
type I interface {
M() uint64
}
type Vertex struct {
X, Y uint64
}
func (v *Vertex) M() uint64 {
return v.X + v.Y
}
func main() {
var i I = &Vertex{3, 4}
describe(i)
i.M()
}
func describe(i I) {
fmt.Printf("(%v, %T)\n", i, i)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment