I have the following in the interpreter in the tour of go:
package main import "fmt" var someString = "one two three four " var words = strings.Fields(someString) var length = len(words) fmt.Println(words, length)
tmp/sandbox216066597/main.go:11: syntax error: non-declaration statement outside function body
I recently corrected it by using
var instead of
:= short syntax outside of any functions, but the error is the same as before.