Scope and initialization
Identifier shadowing
An inner declaration may hide an outer name without changing the outer variable. Use assignment rather than a declaration when updating the existing variable. Example output: '2\n1'.
Formal Syntax & Structure
go syntaxgo
x := value; { x := anotherValue }Working Example
Example Snippetgo
package main
import "fmt"
func main() { n := 1 { n := 2 fmt.Println(n) } fmt.Println(n)}