Note: this question is related to this one, but two years is a very long time in Go history.
What is the standard way to organize a Go project during development ?
My project is a single package mypack, so I guess I put all the .go files in a mypack directory.
But then, I would like to test it during development so I need at least a file declaring the main package, so that I can do go run trypack.go
How should I organize this ? Do I need to do go install mypack each time I want to try it ?
I would recommend reviewing this page on How to Write Go Code
It documents both how to structure your project in a
go buildfriendly way, and also how to write tests. Tests do not need to be a cmd using themainpackage. They can simply be TestX named functions as part of each package, and thengo testwill discover them.The structure suggested in that link in your question is a bit outdated, now with the release of Go 1. You no longer would need to place a
pkgdirectory undersrc. The only 3 spec-related directories are the 3 in the root of your GOPATH: bin, pkg, src . Underneath src, you can simply place your projectmypack, and underneath that is all of your .go files including the mypack_test.gogo buildwill then build into the root level pkg and bin.So your GOPATH might look like this:
export GOPATH=$HOME/projectsUpdate: as of >= Go 1.11, the Module system is now a standard part of the tooling and the GOPATH concept is close to becoming obsolete.