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?
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.
Here is a possible work around creating a build
directory within the checkout as the GOPATH
:
...
def install
system "mkdir -p build/src"
system "ln -s `pwd` build/src/repo"
system "GOPATH=`pwd`/build go get repo/mytool"
bin.install "build/bin/mytool"
...
end
...
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.
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.