github.com/giovannyortegon/go@v0.0.0-20220115155912-8890063f5bdd/src/BlackHatGo/Chap01/Switch/main.go (about) 1 package main 2 3 import "fmt" 4 5 func main() { 6 var x int; 7 8 x = 2 9 10 if x == 1 { 11 fmt.Println("X is equal to 1") 12 } else { 13 fmt.Println("X is not equal to 1") 14 } 15 16 switch x { 17 case 1: 18 fmt.Println("Found 1") 19 case 2: 20 fmt.Println("Found 2") 21 default: 22 fmt.Println("Default case") 23 } 24 25 y := "hola" 26 27 switch y { 28 case "hola": 29 fmt.Println("Found ", y) 30 case "bye": 31 fmt.Println("Found ", y) 32 default: 33 fmt.Println("Default") 34 } 35 36 nums := []int{2,3,4,5} 37 38 for idx, value := range nums { 39 fmt.Println(idx, value) 40 } 41 }