Golang 1.10 is installed in D: \ Program Files \ Go
GOROOT D: \ Program Files \ Go
GOPATH D: \ Program Files \ Go \ Projects
The test project is located in D: \ Program Files \ Go \ Projects \ src \ tmp
Main.go code:
package main import "fmt" func main() { fmt.Println("tmp1") tmp() } The tmp.go file is in the same directory as main.go:
package main import "fmt" func tmp() { fmt.Println("tmp2") } When I run the go run main.go command, I get the error:
command-line-arguments
. \ main.go: 7: 2: undefined: tmp
Why does not the tmp () function call work? After all, main.go and tmp.go are in the same directory and package. And go build works without problems.