github.com/brownsys/tracing-framework-go@v0.0.0-20161210174012-0542a62412fe/go/darwin_amd64/misc/tour/content/flowcontrol/if.go (about) 1 // +build OMIT 2 3 package main 4 5 import ( 6 "fmt" 7 "math" 8 ) 9 10 func sqrt(x float64) string { 11 if x < 0 { 12 return sqrt(-x) + "i" 13 } 14 return fmt.Sprint(math.Sqrt(x)) 15 } 16 17 func main() { 18 fmt.Println(sqrt(2), sqrt(-4)) 19 }