github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2012/goforc/point.go (about) 1 // +build OMIT 2 3 package main 4 5 import "fmt" 6 7 type Point struct{ x, y int } 8 9 func PointToString(p Point) string { 10 return fmt.Sprintf("Point{%d, %d}", p.x, p.y) 11 } 12 13 func (p Point) String() string { // HL 14 return fmt.Sprintf("Point{%d, %d}", p.x, p.y) 15 } 16 17 func main() { 18 p := Point{3, 5} 19 fmt.Println(PointToString(p)) // static dispatch // HL 20 fmt.Println(p.String()) // static dispatch // HL 21 fmt.Println(p) 22 }