84 lines
2.7 KiB
Ruby
84 lines
2.7 KiB
Ruby
class Go < Formula
|
|
desc "Open source programming language to build simple/reliable/efficient software"
|
|
homepage "https://golang.org"
|
|
url "https://golang.org/dl/go1.16.2.src.tar.gz"
|
|
mirror "https://fossies.org/linux/misc/go1.16.2.src.tar.gz"
|
|
sha256 "37ca14287a23cb8ba2ac3f5c3dd8adbc1f7a54b9701a57824bf19a0b271f83ea"
|
|
license "BSD-3-Clause"
|
|
head "https://go.googlesource.com/go.git"
|
|
|
|
livecheck do
|
|
url "https://golang.org/dl/"
|
|
regex(/href=.*?go[._-]?v?(\d+(?:\.\d+)+)[._-]src\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_big_sur: "b5e7afc5fe32df4a9f66f7467be5ec25266c649a942dba2fadf59ec0b31c6f33"
|
|
sha256 big_sur: "b4b8fd4d0e53711f7ad6333146708a1ea61a7063abcfa086f57b1cf3c820e070"
|
|
sha256 catalina: "ad0e76d44fb2f21cd125dc7fb97d2625688ed0cd33c02f9df77efa0a7315f82f"
|
|
sha256 mojave: "17f5ec09c5cdd9251800b402b277df9443d4718c291ff3de4c1a58066c47f991"
|
|
end
|
|
|
|
# Don't update this unless this version cannot bootstrap the new version.
|
|
resource "gobootstrap" do
|
|
on_macos do
|
|
if Hardware::CPU.arm?
|
|
url "https://storage.googleapis.com/golang/go1.16.darwin-arm64.tar.gz"
|
|
version "1.16"
|
|
sha256 "4dac57c00168d30bbd02d95131d5de9ca88e04f2c5a29a404576f30ae9b54810"
|
|
else
|
|
url "https://storage.googleapis.com/golang/go1.16.darwin-amd64.tar.gz"
|
|
version "1.16"
|
|
sha256 "6000a9522975d116bf76044967d7e69e04e982e9625330d9a539a8b45395f9a8"
|
|
end
|
|
end
|
|
|
|
on_linux do
|
|
url "https://storage.googleapis.com/golang/go1.16.linux-amd64.tar.gz"
|
|
version "1.16"
|
|
sha256 "013a489ebb3e24ef3d915abe5b94c3286c070dfe0818d5bca8108f1d6e8440d2"
|
|
end
|
|
end
|
|
|
|
def install
|
|
(buildpath/"gobootstrap").install resource("gobootstrap")
|
|
ENV["GOROOT_BOOTSTRAP"] = buildpath/"gobootstrap"
|
|
|
|
cd "src" do
|
|
ENV["GOROOT_FINAL"] = libexec
|
|
system "./make.bash", "--no-clean"
|
|
end
|
|
|
|
(buildpath/"pkg/obj").rmtree
|
|
rm_rf "gobootstrap" # Bootstrap not required beyond compile.
|
|
libexec.install Dir["*"]
|
|
bin.install_symlink Dir[libexec/"bin/go*"]
|
|
|
|
system bin/"go", "install", "-race", "std"
|
|
|
|
# Remove useless files.
|
|
# Breaks patchelf because folder contains weird debug/test files
|
|
rm_rf Dir[libexec/"src/debug/elf/testdata"]
|
|
end
|
|
|
|
test do
|
|
(testpath/"hello.go").write <<~EOS
|
|
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
fmt.Println("Hello World")
|
|
}
|
|
EOS
|
|
# Run go fmt check for no errors then run the program.
|
|
# This is a a bare minimum of go working as it uses fmt, build, and run.
|
|
system bin/"go", "fmt", "hello.go"
|
|
assert_equal "Hello World\n", shell_output("#{bin}/go run hello.go")
|
|
|
|
ENV["GOOS"] = "freebsd"
|
|
ENV["GOARCH"] = "amd64"
|
|
system bin/"go", "build", "hello.go"
|
|
end
|
|
end
|