if with init statement in Golang

The expression in if statement may be preceded by another statement, which executes before the expression is evaluated.

In the below example - the scope of num is limited to the if statement:

package main

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

func main() {
  rand.Seed(time.Now().UnixNano())
  if  num := -5 + rand.Intn(10); num > 0 {
    fmt.Println("value is positive")
  } else {
    fmt.Println("value is negative")
  }
}