Source file tour/flowcontrol/switch-with-no-condition.go

     1  //go:build OMIT
     2  
     3  package main
     4  
     5  import (
     6  	"fmt"
     7  	"time"
     8  )
     9  
    10  func main() {
    11  	t := time.Now()
    12  	switch {
    13  	case t.Hour() < 12:
    14  		fmt.Println("Good morning!")
    15  	case t.Hour() < 17:
    16  		fmt.Println("Good afternoon.")
    17  	default:
    18  		fmt.Println("Good evening.")
    19  	}
    20  }
    21  

View as plain text