Golang's "declared but not used" nonsense

I mean, come on. I’m doing this project in the golang course and… I just can’t handle it. Look:

package main

import (
  "fmt"
  "math/rand"
  "time"
)

func main() {
  rand.Seed(time.Now().UnixNano())

  var isHeistOn bool = true
  // fmt.Println(isHeistOn)
  eludedGuards := rand.Intn(100)
  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?")
  }
}

See that line that I’ve commented out? The program doesn’t work unless I uncomment it. Says the variable “isHeistOn” is not used. This makes no sense to me, like at all.
I thought it might be some Codecademy platform bug, but no, it works the same everywhere, so apparently this is the intended behaviour? Is there a… you know, NORMAL way around this?

I think it’s mainly to do with the order of operations. Eventually in your program you will use isHeistOn and the problem goes away. (You may write a TODO to fill in the print statement with how you intend to use it).

func main() {
	rand.Seed(time.Now().UnixNano())

	var isHeistOn bool = true
	eludedGuards := rand.Intn(100)
	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?")
	}
	fmt.Println(isHeistOn)
}

or you could defer it functionally, since it can clutter up the main function:

func test(num int) bool {
	if num >= 50 {
		fmt.Println("Looks like you've managed to make it past the guards. Good job, but remember, this is the first step.")
	} else {
        fmt.Println("Plan a better disguise next time?")
		return false	
	}
	return true
}

func main() {
	rand.Seed(time.Now().UnixNano())
	eludedGuards := rand.Intn(100)
	var isHeistOn bool = test(eludedGuards)
	use(isHeistOn) //use it how you will
}

this way it won’t complain until you call the declare the variable which would be right before you use it.

Wait, what constitutes “using” a variable, reading it? But not writing to it?
Ok, clicked now, thank you.

Doing any operation with it (it can be a read or some other function). Assigning it isn’t enough.