Conditions / Loops

if/else, for and struct

If condition

package main

import (
	"fmt"
//	"math"
)


func main() {
	
	// conditions: if/else/if-else, no ternary operator (a?b:c)
	
	if 3%2 == 0{
		fmt.Println("even")
	}
	else{
	fmt.Println("odd")
	}
	
	}
  • No parenthesis required in conditions

  • There is no ternary operator in Go

For loop

switch

Last updated

Was this helpful?