HomeToolsAbout a20k

Conditionals

What is it

// comparison operator if condition == "true" { ... } // logical NOT operator if !condition == "true" { ... } // logical AND if ( a && b ) { fmt.Printf("Condition is true") } // logical OR if ( a || b ) { fmt.Printf("Condition is true") }

if, else if, else

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") }
© VincentVanKoh