Golang mixed assignation and declaration
I started working with go for a few weeks, and (once again) I stumbled across something that seems odd for me: // Not working a := 1 { a, b := 2, 3 } // Works a := 1 a, b := 2, 3 playground I want to assign two variables simultaneously. One is already declared, in a superior scope, the other one is not. It does not work: the compiler tries to redeclare the former variable. However, it works fine if this variable is declared in the same scope. Why is that ? What you're experiencing is commonly known as "variable shadowing" . When you use := with any variable in an inner scope, including in