Source file tour/flowcontrol/if.go

     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  }
    20  

View as plain text