Source file tour/methods/methods.go
1 //go:build OMIT 2 3 package main 4 5 import ( 6 "fmt" 7 "math" 8 ) 9 10 type Vertex struct { 11 X, Y float64 12 } 13 14 func (v Vertex) Abs() float64 { 15 return math.Sqrt(v.X*v.X + v.Y*v.Y) 16 } 17 18 func main() { 19 v := Vertex{3, 4} 20 fmt.Println(v.Abs()) 21 } 22