I just started writing Go today (so 0 experience), and wonder if Go supports any form of "building all source files" like what mvn install
does.
My project structure is
src
`-github.com
`-myproject
|- package1
| `- main.go
`- package2
|- lib1_used_by_main.go
`- lib2_used_by_main.go
When I do
cd src/github.com/myproject
go build
this fails with no buildable Go source files in src/github.com/myproject
, which is kind of right, because all source files are in subpackages.
Is there a command to build all subpackages, without listing each of them explicitly?
go build
on a non-main package doesn't produce any artifacts.go/pkg
. Anything (e.g. IDE) that relies on thego/pkg
folder will benefit from being properly up to date. See my answer.go build
docs:When compiling multiple packages or a single non-main package, build compiles the packages but discards the resulting object, serving only as a check that the packages can be built.
If you want to save the build artifacts, you can usego install
orgo build -i
.margo
from GoSublime intercepts the results for the purpose of updating the autocompletion then? Either way, simply building my package after adding a new function (etc) updates my autocompletion.