Not noise. You highlight a very dumb rule of the syntax in my opinion. The mixing of new and old declarations with new variables possibly being introduced or old ones shadowed. 

I know it won’t/can’t change - but took the opportunity to rant :)

On Jan 14, 2026, at 7:54 AM, 'Brian Candler' via golang-nuts <[email protected]> wrote:

OK, it's a block scope thing, because using an "if" statement I can also violate the rule that "at least one of the non-blank variables is new".

https://go.dev/play/p/9_B8OZQFe_n

func main() {
var code int
var err error
if code, err := myfunc(); err != nil {  // this is accepted
fmt.Printf("Error: %s", err)
_ = code
return
}
fmt.Printf("code is %d, err is %v", code, err)  // 0, <nil>
}

So I need to imagine a curly bracket enclosing the whole 'if' statement.

Sorry for the noise.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/67a77745-1391-46b1-99dd-7a2cf4a0f496n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/557046C6-8583-4A1C-899C-8B808C08979D%40ix.netcom.com.

Reply via email to