main packageが複数ファイルで構成される時のgo run

main.go

package main

func main() {
    some()
}

some.go

package main

import (
    "fmt"
)

func some() {
    fmt.Println("some")
}

というのがある時に、go run main.go ってやると動きそうな気がするんだけど、動かない。

Run compiles and runs the main package comprising the named Go source files.
A Go source file is defined to be a file ending in a literal ".go" suffix.

とあるように、go run main.go とやっただけでは、main.goだけがコンパイルされる。同一packageゆえにmain.goからのimportなど明示的な依存関係があるわけではないので、some.goがコンパイルされることはない。

go run main.go some.go なり go run *.go なりしてやる必要がある。