Golang (Go) Tutorial - Control Flow - If/Else
๐ If-Else - Decisions
Real Life:
๐ Exam Result:
If marks >= 40 โ Pass
Else โ Fail
๐ก๏ธ Weather:
If temp > 30 โ Hot
Else if temp > 20 โ Normal
Else โ Cold
Syntax
if condition {
// code
} else if condition {
// code
} else {
// code
}
๐ก Go Special:
No parentheses needed!
Curly braces required (even for 1 line)
Example
if age >= 18 {
fmt.Println("Adult")
} else {
fmt.Println("Minor")
}