I am new to go and currently going through the go tool tour
.
While on the Short variable declarations section, I modified the sample code to look like this?
package main
import "fmt"
func main() {
var i, j int = 1, 2
k := 3
var c bool, python string = true, "test"
fmt.Println(i, j, k, c, python)
}
However, then I run the above code, I get the error:
# command-line-arguments
./compile233.go:8:12: syntax error: unexpected comma at end of statement
However, if I remove the types from the var
declaration like the following:
package main
import "fmt"
func main() {
var i, j int = 1, 2
k := 3
var c, python = true, "test"
fmt.Println(i, j, k, c, python)
}
It works.
I cannot figure out what is wrong with the first example, and the error seems a bit misleading to me. Could anyone explain what I did wrong and why I'm getting the error?