[Solved] #command-line-arguments .\main.go:5:4: no new variables on left side of :=

# command-line-arguments
.\main.go:5:4: no new variables on left side of :=
package main
import “fmt”
func main(){
var b int;
b := 1;
fmt.Println(b);
}

The correct way to write it: remove the : or add a new variable
package main
import “fmt”
func main(){
var b int;
b,a := 1,2;
fmt.Println(b,a);
}
// No compile error is generated at this point because a new variable is declared, because := is a declaration statement

 


Read More: