Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to package go project for homebrew

We're developing runscripts and try to support something like brew install runscripts.

It's written in golang and have some dependencies which required to go get. Now I have no idea to write the Formula to setup GOPATH and run go get. Our project can be compiled into an binary but we need run --init to install it.

Can anyone helps to give an example about a homebrew Formula of go project?

like image 852
tobe Avatar asked Nov 24 '14 02:11

tobe


4 Answers

Fork homebrew, look at the content of Library/Formula/consul.rb. You don't need to manually generate all the resources. Use homebrew-go-resources. A more complete intro could be found here.

like image 110
Tyr Avatar answered Oct 16 '22 19:10

Tyr


I have refer to termshare.rb and it seems we can simply go get and homebrew will handle anything about GOPATH for us.

That's great and I think my problem is solved.

like image 29
tobe Avatar answered Oct 16 '22 18:10

tobe


The best I could find is how docker-swarm is added to brew: https://github.com/Homebrew/homebrew/blob/4c6857b0e337b2d5afd49dcf7209b6b5091709f4/Library/Formula/docker-swarm.rb

It's relatively clean and simple to follow.

like image 1
Viktor Benei Avatar answered Oct 16 '22 18:10

Viktor Benei


You can use goreleaser to generate the formula automatically: https://goreleaser.com/customization/homebrew/

like image 1
davegallant Avatar answered Oct 16 '22 20:10

davegallant