Golang: run all .go files within current directory through the command line (multi file package) -


i'm newcomer go. extremely language, realised needed start dividing files due increase in program size.

go run main.go (with main.go having been file main() function)

didn't work , hit barrier while, because had no clue how program working.

some quick searching lead me answer of

go run main.go other.go ..

where typing files package main consists of, programming running. however, utterly cumbersome , frustrating each time.

i write following self-answered question in order prevent others myself may again hit barrier.

as nate finch notes:

go run ... meant used on small programs, need single file.

even on unix, go run *.go not correct. in project unit tests (and every project should have unit tests), give error:

go run: cannot run *_test.go files (something_test.go) 

it ignore build restrictions, _windows.go files compiled (or attempted compiled) on unix, not want.

there has been bit of discussion of making go run work rest of go commands, , there's open cl (5164). it's under consideration go 1.4. in meantime, recommended solution on platforms is:

go build && ./<executable> 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -