> Apparently Dave Cheney says to prefer "go install" over "go build"[3], except when cross-compiling [4]. However, many of these posts are older, and Golang moves at such a rapid clip that it's difficult to keep track of what everybody is doing.
This information is still correct. On Friday, 10 February 2017 02:55:25 UTC+11, Jonathan Yu wrote: > > Hello Gophers! > > There's a fair amount of documentation available[0] about how "go install" > works, particularly in contrast to "go build,"[1,2] but not a lot about > which one is more idiomatic/preferred. Using the standard toolchain, it > seems there's three ways to build your applications: > > - go build > - go build -i > - go install > - Are there more that I'm unaware of? Are some preferred in certain > circumstances (for example, "go install" for development, "go build" on CI > or for building *.rpm and *.deb packages?) > > Apparently Dave Cheney says to prefer "go install" over "go build"[3], > except when cross-compiling [4]. However, many of these posts are older, > and Golang moves at such a rapid clip that it's difficult to keep track of > what everybody is doing. > > Larger projects tend to use a bunch of shell scripts, so it can be > difficult to tell what they're doing underneath, but I just did a quick > survey: > > Kubernetes[5] and OpenShift[6] use "go install" to build, and a cursory > search of those repositories shows a healthy mix of both "go build" and "go > install" amongst vendored libraries. Docker appears to use "go build"[7]. > > That Heartbleed/Ticketbleed guy with the great hair builds with "go test > -i" if I'm reading the hellogopher code correctly[8]. > > Tim Hockin's boilerplate project uses "go install"[9]. > > Hopefully I didn't just accidentally start a flamewar/bikeshedding session > with this question... Seems like an important thing to settle. I'm curious > to hear your thoughts! > > Cheers, > > Jonathan > > [0] > https://golang.org/cmd/go/#hdr-Compile_and_install_packages_and_dependencies > [1] > https://github.com/NanXiao/golang-101-hacks/blob/master/posts/go-build-vs-go-install.md > [2] > https://www.quora.com/What-is-the-difference-between-build-and-install-in-Go > [3] https://peter.bourgon.org/go-best-practices-2016/#build-and-deploy > [4] https://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5 > [5] > https://github.com/kubernetes/kubernetes/blob/3897fc00db947c5f782a8b9c68602339b16deeaa/hack/lib/golang.sh#L478-L481 > [6] > https://github.com/openshift/origin/blob/6d206d23bdf3654df3537ba034fa5bc7e5ad4697/hack/common.sh#L223-L228 > > (I think this was copied from k8s) > [7] > https://github.com/docker/docker/blob/c07234707878412eaaeab252af19adac8cf25d6b/hack/make/.binary#L34-L42 > [8] https://github.com/cloudflare/hellogopher/blob/master/Makefile#L33 > [9] > https://github.com/thockin/go-build-template/blob/43e119bda6199d80ecf6982b05b837e091aaeeba/build/build.sh#L37-L40 > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.