golang if syntax code example

Example 1: if statements in go

a := 4
b := 6
if a + b == 10 {
  fmt.Println("a + b is equal to 10!")
} else {
  fmt.Println("a + b does not equal 10...")
}

Example 2: if else i golang

package main
import "fmt"
func main() {
    if 7%2 == 0 {
        fmt.Println("7 is even")
    } else {
        fmt.Println("7 is odd")
    }

    if 8%4 == 0 {
        fmt.Println("8 is divisible by 4")
    }

    if num := 9; num < 0 {
        fmt.Println(num, "is negative")
    } else if num < 10 {
        fmt.Println(num, "has 1 digit")
    } else {
        fmt.Println(num, "has multiple digits")
    }
}