3 ms·
I like Makefiles and Makefiles for Go are especially simple, but they don't play well with "go get", do they?
by tptacek 9y ago
I like Makefiles and Makefiles for Go are especially simple, but they don't play well with "go get", do they?
- insertnickname 9y agoJust because you have a Makefile in your repository, it doesn't mean the package(s) aren't `go get`-able. As long as the package can be built with `go install`/`go build` it should be fine.
- jerf 9y agoAnd there are cases where it is simply impossible for the package to be installed simply with "go get" or "go install". C'est la vie. The idea is not to unnecessarily introduce dependencies on things like make, not that you can remove the necessary dependencies on external tools.
- tptacek 9y agoRight, but then the value of the Makefile is pretty marginal.
- jeffinhat 9y agoThe value of the Makefile is for automating repetitive dev tasks. Consumers of a golang CLI should use `go get` but this makes it easier for contributors who run tests, cut releases, .. The authors example is clean/simple. Here's an example not so clean/simple example where we needed to do more complex stuff like build for all target platforms[1]. [1] https://github.com/cloudfoundry-community/stackdriver-tools/blob/master/src/stackdriver-nozzle/Makefile https://github.com/cloudfoundry-community/stackdriver-tools/...
- chimeracoder 9y ago> I like Makefiles and Makefiles for Go are especially simple, but they don't play well with "go get", do they? They don't (`go get` won't execute anything defined in a Makefile), and the approach that the author takes to vendoring is also going to cause problems. It's possible to have a Makefile that serves as a shim for the standard and recommended Go workflow, but it's not very easy, and it's ultimately an uphill battle. It's also not going to be cross-platform, unlike the Go toolchain.
- kasey_junk 9y agoWe don't use makefiles for cascading builds like you would in C and as such a lot of the power of Makefiles is lost in the golang world. We do use them to specify "simple" repetitive tasks in a uniform way, with some minimal amount of order defined (for instance making sure go get is called before go test, or our code for embedding version numbers into binaries for builds). [edit] An example from one of our public repos https://github.com/MediaMath/grim/blob/master/Makefile https://github.com/MediaMath/grim/blob/master/Makefile the codebase was one of our first times writing go so we aren't terribly proud of it, but the Makefile is representative of the kinds of things we do in make.