github.com/EngineerKamesh/gofullstack@v0.0.0-20180609171605-d41341d7d4ee/volume1/section2/conditionals/conditionals.go (about) 1 // Examples of conditional logic and impact on the flow of control. 2 package main 3 4 import "fmt" 5 6 func main() { 7 8 x := 9 9 10 // An if statement 11 if x == 9 { 12 fmt.Println("x is equal to 9") 13 } 14 15 // An if statement followed by an else statement example 16 if y := 18; y == 18 { 17 fmt.Println("y is equal to 18") 18 } else { 19 fmt.Println("y is not equal to 18") 20 } 21 22 z := 36 23 // An if - else if - else example 24 if z == 1 { 25 fmt.Println("z is equal to 1") 26 27 } else if z == 2 { 28 fmt.Println("z is equal to 2") 29 30 } else if z == 3 { 31 fmt.Println("z is equal to 3") 32 33 } else { 34 fmt.Println("z does not equal 1, 2, or 3") 35 } 36 37 }