Go Bank Heist Go Project

I can’t seem to figure out why my code isn’t working

package main

import (
“fmt”
“math/rand”
“time”
)

func main() {
isHeistOn := true
eludedGuards := rand.Intn(100)
rand.Seed(time.Now().UnixNano())
if eludedGuards >= 50 {
fmt.Println(“Looks like you’ve managed to make it past the guards. Good job, but remember, this is the first step.”)
else isHeistOn := false {
fmt.Println(“Plan a better disguise next time?”)
} if isHeistOn := true && openedVault >= 70
openedVault := rand.Intn(55) {
fmt.Println(“Grab and GO!”)
} else if isHeistOn := true || openedVault <= 70 {
isHeistOn = false
fmt.Println(“Plan a better disguise next time?”)
}
leftSafely := rand.Intn(5)
if isHeistOn := true {
switch leftSafely {
case 0:
isHeistOn = false
fmt.Print(“Looks like you tripped an alarm… run?”)
case 1:
isHeistOn = false
fmt.Print(“Turns out vault doors don’t open from the inside…”)
case 2:
isHeistOn = false
fmt.Print(“The alarm went off…”)
case 3:
isHeistOn = false
fmt.Print(“Cops are coming…”)
default:
fmt.Println(“Start the getaway car!”)
}
if isHeistOn := true {
amtStolen = 10000 + rand.Intn(1000000)
fmt.Println("$", amtStolen, “not bad!”)
}
}
fmt.Println(“isHeistOn is currently:”, isHeistOn)
}

After I run the code I get this error message.

command-line-arguments

./main.go:15:10: syntax error: else must be followed by if or statement block
./main.go:17:5: syntax error: unexpected if after top level declaration

The error is telling you what is wrong.

./main.go:15:10: syntax error: else must be followed by if or statement block

On line 15, you have this:
if eludedGuards >= 50 {

There’s nothing wrong with this line specifically, so let’s have a look a bit further down. The error mentions else, so if we look at the following block…

    if eludedGuards >= 50 {
    fmt.Println(“Looks like you’ve managed to make it past the guards. Good job, but remember, this is the first step.”)
    else isHeistOn := false {

There’s no closing } for your original if… so the else statement is unexpected, hence the error.

Next error is ./main.go:17:5: syntax error: unexpected if after top level declaration but I think this is related to the missing } mentioned already. :slight_smile: