Conditionals in Go
From the Go cheat sheet · Control Flow · verified Jul 2026
Conditionals
If statements and switch cases
go
// If statement
if x > 0 {
fmt.Println("Positive")
} else if x < 0 {
fmt.Println("Negative")
} else {
fmt.Println("Zero")
}
// Switch
switch day {
case 1:
fmt.Println("Monday")
case 2:
fmt.Println("Tuesday")
default:
fmt.Println("Other")
}🎯 No parentheses needed around conditions
🔄 Switch doesn't need break (no fallthrough by default)
📦 Type switches for interface type assertion
⚡ Switch can be used without an expression