Control Structures
If/else
if choice == 1 {
fmt.Printf("Your balance is: %.2f GO", accountBalance)
} else if choice == 2 {
var depositAmount float64
fmt.Print("How much GO do you want to deposit: ")
fmt.Scan(&depositAmount)
accountBalance += depositAmount
fmt.Printf("New account balance: %.2f GO", accountBalance)
}if depositAmount <= 0 {
fmt.Println("Deposit amount must be greater than 0.")
return
}func main() {
fmt.Println("Hello World")
name := "Halula"
if lenName := len(name); lenName == 6 {
fmt.Println("Longer than 6")
}
}For loops
Switch Statements
Last updated