I want to write a Homebrew formula for installing a Go package and its dependencies. Here's what I've got so far:
class LsGo < Formula
desc "A more colorful, user-friendly implementation of `ls` written in Go"
homepage "https://github.com/acarl005/ls-go"
url "https://github.com/acarl005/ls-go/archive/v0.0.0.tar.gz"
sha256 "db9ba7300fbbaf92926b2c95fd63e3e936739e359f123b5a45e6ca04b490af51"
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
(buildpath/"src/github.com/acarl005").mkpath
ln_s buildpath, buildpath/"src/github.com/acarl005/ls-go"
system "cd", buildpath/"src/github.com/acarl005/ls-go"
system "go", "get", "./"
system "cd", "-"
system "go", "build", "-o", bin/"ls-go"
end
test do
system bin/"ls-go", "--help"
end
end
But I get an error about running go get ./
outside the $GOPATH
.
==> cd /private/tmp/ls-go-20180612-22435-oidqms/ls-go-0.0.0/src/github.com/acarl005/ls-go
==> go get ./
Last 15 lines from /Users/andy/Library/Logs/Homebrew/ls-go/02.go:
2018-06-12 16:31:14 -0700
go
get
./
go get: no install location for directory /private/tmp/ls-go-20180612-22435-oidqms/ls-go-0.0.0 outside GOPATH
This doesn't make sense to me. I set ENV["GOPATH"]
to /private/tmp/ls-go-20180612-22435-oidqms/ls-go-0.0.0/
, and I cd'ed into a subdir of that path. Why is it saying I'm outside the $GOPATH
?
How should I get the dependencies for my package?
EDIT: I'd prefer to avoid vendoring packages.