Statement
If initializer
An optional simple statement executes before the condition. Variables declared by it are visible in the condition and both branches but not after the if statement. Example output: '3'.
Formal Syntax & Structure
go syntaxgo
if init; condition { ... }Working Example
Example Snippetgo
package main
import "fmt"
func main() { if n := 3; n > 5 { fmt.Println("large") } else { fmt.Println(n) }}