Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Homebrew Formula for a Go app

Homebrew Formula for a Go app

These are quick notes from making my own Formula and Tap.

Add go build script to your Git repo


set -eux

export GOPATH="$(pwd)/.gobuild"

[ -d ${GOPATH} ] && rm -rf ${GOPATH}
mkdir -p ${GOPATH}/{src,pkg,bin}
mkdir -p ${SRCDIR}
cp tf.go ${SRCDIR}
    echo ${GOPATH}
    cd ${SRCDIR}
    go get .
    go install .

Create tar.gz

You can do this by tagging your Github repository with a version.

Update Brew

brew update

Create Formula skel

brew create ''

Modify Formula


class Tf < Formula
  homepage ""
  url ""
  sha256 "b59730cfbc3c62027bd91942c70d3d07c2bbc4f82b0332d17da977bb7f2041bc"

  depends_on "go" => :build

  def install
    system ""
    bin.install ".gobuild/bin/tf" => "tf"

  test do
    system "#{bin}/tf", "--help"

Audit Formula

brew audit --strict tf

Test local install

HOMEBREW_MAKE_JOBS=1 brew install -v tf

Github pull request

Github pull request

Make your own Tap

Create a Git repo called "homebrew-something".

Add your formula to the root of the repo. After this you can use it like:

The "name" should not include "homebrew-" which is a prefix

brew tap mickep76/funk-gnarge
brew install mickep76/funk-gnarge/tf
Copy link

Solorad commented Apr 30, 2019

@Mickep76 hello!
Can you please write a little bit more about step Github pull request? What is it for? The main repository where released archive is already present? Or what?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment