Source file tour/methods/methods-funcs.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 Abs(v Vertex) 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(Abs(v))
    21  }
    22  

View as plain text