Declaration

Short declaration redeclaration

A short declaration can reuse a same-block variable with its existing type if at least one nonblank name is new. Function parameters also qualify in the function body. An inner block instead introduces a separate variable. Example output: '4 ready'.

Formal Syntax & Structure

go syntaxgo
name, newName := expressions

Working Example

Example Snippetgo
package main
import "fmt"
func main() {  n := 3  n, label := 4, "ready"  fmt.Println(n, label)}
Go Reference