no new variables on left side of :=
Go Programming Language
Severity: MinorWhat it means
The message: no new variables on left side of :=.
Go's compiler docs: a short variable declaration (:=) doesn't declare any new variable.
The Go spec: := may redeclare variables declared earlier in the same block, but only if at least one of the names on the left is new.
Affected Models
- The Go compiler (go build, go run, go test)
How to Fix It
-
Changing a variable that already exists? Use = instead: x = 2, not x := 2.
-
Two results, such as v, err := f(), when v and err both exist already? Use =, or give one of them a new name.