`main.go`
```go
package main
import "fmt"
func main() {
fmt.Println("Hello!")
hey()
}
```
`hey.go`
```go
package main
import "fmt"
func hey() {
fmt.Println("Hey!")
}
```
这两个文件都在同一个目录下,运行 `go run main.go` 的时候报错`./main.go:9:2: undefined: hey`
go 版本: go1.15.6.linux-amd64
```shell
go run [build flags] [-exec xprog] package [arguments...]
```
Run compiles and runs the named **main** Go package. Typically the package is specified as **a list of .go source files** from a single directory, but it may also be an import path, file system path, or pattern matching a single known package, as in 'go run .' or 'go run my/cmd'.
[go run](https://golang.org/cmd/go/#hdr-Compile_and_run_Go_program)
#9