/* * The Go switch statement. */ package main import "fmt" func main() { // Read an item fmt.Printf("==> "); var val int; fmt.Scan(&val) switch { // Switch expression defaults to true case val % 11 == 0: fmt.Printf("%d is divisible by 11. Wow!\n", val) case val % 7 == 0: fmt.Printf("%d is divisible by 7, but not by 11.\n", val) case val <= 0: fmt.Printf("Your number %d is not very positive.\n", val) case val >= 100 && val <= 1000: fmt.Printf("The number %d is between 100 and 1000, " + "inclusive\n", val) case val & (val - 1) == 0: fmt.Printf("The number %d is a power of 2.\n", val) default: fmt.Printf("%d is boring.\n", val) } }