package main import ( "fmt" ) var balance float64 = 0 func main() { deposit(.1) deposit(.2) if balance, ok := withdraw(0.30000000000000004); ok { fmt.Println(balance) } } func deposit(v float64) { balance += v } func withdraw(v float64) (float64, bool) { if v <= balance { balance -= v return v, true } return 0, false }