I\'m a newcomer to Go. I extremely like the language, but I quickly realised that I needed to start dividing my files due to an increase in program size.
go r
As Nate Finch notes:
Go run is ... really only meant to be used on very small programs, which generally only need a single file.
Even on unix, go run *.go
is often not correct. In any project with unit tests (and every project should have unit tests), this will give the error:
go run: cannot run *_test.go files (something_test.go)
It will also ignore build restrictions, so _windows.go
files will be compiled (or attempted to be compiled) on Unix, which is not what you want.
There has been a bit of discussion of making go run
work like the rest of the go
commands, and there's an open CL for it (5164). It's currently under consideration for Go 1.4. In the meantime, the recommended solution on all platforms is:
go build && ./