Hi, I am wondering what is the recommended way to package a Unix binary written in Go.
What I want, to adhere to standard Unix conventions: - Something like "./configure --prefix=/opt/foo" that "does something" to set a final install location. It should also autodetect possible optional dependencies and set up "some" infrastructure to use or not use them (e.g. conditional compilation by enabling/disabling inclusion of a subpackage that self-registers via an init() function or by having multiple source files with different build tags defining the same interface). As we're talking about Go which already has "go get", this should have the option (probably enabled by default, but to be disabled by distribution package maintainers to make builds hermetic) to download missing packages. - Something like "make". Well, that'd be "go build". Easy. - Something like "make install" that copies generated executables to /opt/foo/bin, while defaulting to /usr/local/bin (and probably everything else to $GOPATH) but _will never compile_ so it's safe to run via sudo without potentially messing up the source tree with root-owned files. Too bad "go install" first requires the user to set up GOBIN... - It should feel to the package's user just like one of the wellknown standard build systems like autoconf (e.g. waf and meson feel "sufficiently like this") or cmake (the weird one out there but it's becoming common enough that it can be assumed that users have seen it before). Why? I don't believe the mere user of a package is supposed to learn a different build system for each project. - Of course stuff like cross compiling and installing into a staging location (e.g. via $DESTDIR) should be supported and easy. - While at it, it should also be able to install config files into $prefix/etc, and make the install prefix "somehow known" to the compiled program so it can know where to read its config files from. And documentation goes into $prefix/doc, helper binaries into $prefix/libexec/somesubdir, etc... Now I know I can probably build all this with my own shell script hackery; after all, "Makefile.in" only would have to be a simple wrapper with something like DESTDIR = all: go build install: install binary $(DESTDIR)@bindir@/binary However, I'd prefer something more "standardized". Stuff I could already find: https://github.com/mutse/go-cmake (seems some hackery but should work... just seems bad to have to copy the Go-specific parts into each specific project) https://github.com/google/blueprint (maybe? can't quite tell if this also has a "make install" like functionality) https://medium.com/palantir/g%C3%B6del-a-build-system-for-the-go-programming-language-9f7d2a4974e8 (has all but installing) https://gist.github.com/dnishimura/2961173 (seems to try to solve the same problem, but far from done and assumes GOPATH, and no cross compilation) https://sohlich.github.io/post/go_makefile/ (more of a tutorial how to somehow integrate with make than a solution, but still, good try; lacks "install" of course, and cross compilation is very... specific) https://github.com/dreadl0ck/zeus (doesn't solve the problem at all, has same problem as raw make: you create your own command names and usage convention, do not want) Rudolf -- 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.