I think this is little weird, why does this code does not work?
package main
import "fmt"
func main() {
var i, j int = 1, 2
k := 3
c, python, go := true, false, false
fmt.Println(i, j, k, c, python, go)
}
Throws error
# command-line-arguments
.\compile64.go:8:13: syntax error: unexpected go, expecting expression
.\compile64.go:10:29: syntax error: unexpected go, expecting expression
But this worked!
package main
import "fmt"
func main() {
var i, j int = 1, 2
k := 3
c, python, goo := true, false, false
fmt.Println(i, j, k, c, python, goo)
}
Is "go" a reserved word in Golang?
Yes, a keyword:
break default func interface select
case defer go map struct
chan else goto package switch
const fallthrough if range type
continue for import return var
Yes, go
is a reserved word to run goroutines, the language's main concurrency feature.