go build builds a binarygo install moves this binary to $GOPATH/binlibc; producing an executable with no linked dependenciesCGO_ENABLED=0 go build -a -tags netgo,osusergo -ldflags "-extldflags '-static' is -w" -o a.out .
libc or other runtime dependencies)$GOARCH for your architecture (e.g. amd64, arm64), $GOOS for the OS you want (e.g. linux, darwin) and $GOARM specifically for the ARM chip version (e.g. 7)GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=0 go build -a -tags netgo,osusergo -ldflags "-extldflags '-static' -w" -o a.out ./main.go
cmd/ is used for the main executable programpkg/ is used for any custom librariestest/ is for any separate integration tests
package_test.go stored with the package itself in the same directory-ldflags "-X main.version=$(VERSION)", with a variable defined like VERSION=$(shell git describe --tags --long --dirty 2>/dev/null)