Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save codecakes/801409fbf3c889ff61d029d03ace71ea to your computer and use it in GitHub Desktop.
if you are not returning, the implementation method type is not needed
package main
import "fmt"
type I interface {
M() // uint64
}
type Vertex struct {
X, Y uint64
}
func (v *Vertex) M() {
fmt.Println(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