Alex W.'s Blog

Different Homebrew formula approaches (for `go` binaries)

homebrew-core requires binaries to be compiled from source, you can’t just download an asset from GitHub Releases and then use the bin.install command to setup the binary.

If you’d prefer to use the pre-compiled you can’t introduce your tool into homebrew-core, ie. it won’t be installable with brew install toolname. Instead you can create a tap (such as croc which allows brew install schollz/tap/croc and maps to schollz/homebrew-tap/Formula/croc.rb on GitHub) or you can create a Formula file for direct reference (such as the pup.rb file in the ericchiang/pup GitHub repo). GoReleaser has support for maintaining Homebrew taps.

If you do want to include it in homebrew-core you can follow the example of homebrew-core/Formula/pup.rb which uses homebrew dependencies on go and gox to build. Your go project must be vendored though, ie. you can’t use go get in the build step, for the homebrew-core maintainers to accept it.

Written by Alex Wendland, who is currently exploring fintech at Pinwheel. Here's a Twitter handle, a GitHub, some LinkedIn, ol' Facebook, or a hip Instagram if you're interested.