Source file tour/flowcontrol/switch.go

     1  //go:build OMIT
     2  
     3  package main
     4  
     5  import (
     6  	"fmt"
     7  	"runtime"
     8  )
     9  
    10  func main() {
    11  	fmt.Print("Go runs on ")
    12  	switch os := runtime.GOOS; os {
    13  	case "darwin":
    14  		fmt.Println("OS X.")
    15  	case "linux":
    16  		fmt.Println("Linux.")
    17  	default:
    18  		// freebsd, openbsd,
    19  		// plan9, windows...
    20  		fmt.Printf("%s.\n", os)
    21  	}
    22  }
    23  

View as plain text