From 51ce46df8e482aa17f47e6264657731499929563 Mon Sep 17 00:00:00 2001 From: Vladislav Bardusov Date: Sat, 19 Mar 2022 17:24:42 +0400 Subject: [PATCH] Go update to 1.18 --- Formula/go.rb | 6 +-- Formula/go@1.18.rb | 93 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 Formula/go@1.18.rb diff --git a/Formula/go.rb b/Formula/go.rb index a4ef8fac5ce4..7c7dc90c5aee 100644 --- a/Formula/go.rb +++ b/Formula/go.rb @@ -1,9 +1,9 @@ class Go < Formula desc "Open source programming language to build simple/reliable/efficient software" homepage "https://go.dev/" - url "https://go.dev/dl/go1.17.8.src.tar.gz" - mirror "https://fossies.org/linux/misc/go1.17.8.src.tar.gz" - sha256 "2effcd898140da79a061f3784ca4f8d8b13d811fb2abe9dad2404442dabbdf7a" + url "https://go.dev/dl/go1.18.src.tar.gz" + mirror "https://fossies.org/linux/misc/go1.18.src.tar.gz" + sha256 "38f423db4cc834883f2b52344282fa7a39fbb93650dc62a11fdf0be6409bdad6" license "BSD-3-Clause" head "https://go.googlesource.com/go.git", branch: "master" diff --git a/Formula/go@1.18.rb b/Formula/go@1.18.rb new file mode 100644 index 000000000000..5decacc61ce4 --- /dev/null +++ b/Formula/go@1.18.rb @@ -0,0 +1,93 @@ +class GoAT118 < Formula + desc "Open source programming language to build simple/reliable/efficient software" + homepage "https://go.dev/" + url "https://go.dev/dl/go1.18.src.tar.gz" + mirror "https://fossies.org/linux/misc/go1.18.src.tar.gz" + sha256 "38f423db4cc834883f2b52344282fa7a39fbb93650dc62a11fdf0be6409bdad6" + license "BSD-3-Clause" + head "https://go.googlesource.com/go.git", branch: "master" + + livecheck do + url "https://go.dev/dl/" + regex(/href=.*?go[._-]?v?(\d+(?:\.\d+)+)[._-]src\.t/i) + end + + bottle do + sha256 arm64_monterey: "6537caf925f0a3ec1875c55b88a4184d58fc604f6979397b22e4b2a257175af1" + sha256 arm64_big_sur: "fdc0d8e3047cc35f601e1b8c8381bd50594711db9b90e81f01430b864a8ef579" + sha256 monterey: "8e95cccc916d40254e2a56449fac8f4a5e36d86d63b619793ff1f372bae387a1" + sha256 big_sur: "62e6d0bdf5effc5b98f5de7004f7c70e4f27f120f334302622829f37f65676e8" + sha256 catalina: "7d769c4b648931964a38850fa2774d40d2832ebecfeba97c35645f430ba80ab4" + sha256 x86_64_linux: "2c529a79f41ffc505361700c502661d9b6e0e11050d86f5dc6ff488ce854f4ac" + 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 + if Hardware::CPU.arm? + url "https://storage.googleapis.com/golang/go1.16.linux-arm64.tar.gz" + version "1.16" + sha256 "3770f7eb22d05e25fbee8fb53c2a4e897da043eb83c69b9a14f8d98562cd8098" + else + url "https://storage.googleapis.com/golang/go1.16.linux-amd64.tar.gz" + version "1.16" + sha256 "013a489ebb3e24ef3d915abe5b94c3286c070dfe0818d5bca8108f1d6e8440d2" + end + 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 + (libexec/"src/debug/elf/testdata").rmtree + # Binaries built for an incompatible architecture + (libexec/"src/runtime/pprof/testdata").rmtree + 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