Skip to content
2 changes: 1 addition & 1 deletion Formula/c/clair.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Clair < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "bb434c8789c0d0b1fe858eb2573cd97a9c52cf34b04872b03126a10ace8f43b6"
end

depends_on "go" => :build
depends_on "go@1.21" => :build # use "go" again when https://github.com/quay/clair/pull/1942 is released
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can also include the patch to ship with go1.22, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patching go.mod / go.sum is prone to conflicts, so we'd have to make a new patch specifically for the old release commit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are > 100 commits since the last release, confirming my suspicion: quay/clair@v4.7.2...main


def install
ldflags = %W[
Expand Down
2 changes: 1 addition & 1 deletion Formula/c/coder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Coder < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "69338571ea5bc8a0891ffa3ffe6eee65453ea35263954dd2062f49b851ae25aa"
end

depends_on "go" => :build
depends_on "go@1.21" => :build # see https://github.com/coder/coder/issues/11342

def install
ldflags = %W[
Expand Down
88 changes: 88 additions & 0 deletions Formula/g/go@1.21.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
class GoAT121 < Formula
desc "Open source programming language to build simple/reliable/efficient software"
homepage "https://go.dev/"
url "https://go.dev/dl/go1.21.7.src.tar.gz"
mirror "https://fossies.org/linux/misc/go1.21.7.src.tar.gz"
sha256 "00197ab20f33813832bff62fd93cca1c42a08cc689a32a6672ca49591959bff6"
license "BSD-3-Clause"

livecheck do
url "https://go.dev/dl/?mode=json"
regex(/^go[._-]?v?(1\.21(?:\.\d+)*)[._-]src\.t.+$/i)
strategy :json do |json, regex|
json.map do |release|
next if release["stable"] != true
next if release["files"].none? { |file| file["filename"].match?(regex) }

release["version"][/(\d+(?:\.\d+)+)/, 1]
end
end
end

keg_only :versioned_formula

depends_on "go" => :build

def install
ENV["GOROOT_BOOTSTRAP"] = buildpath/"gobootstrap"

cd "src" do
ENV["GOROOT_FINAL"] = libexec
# Set portable defaults for CC/CXX to be used by cgo
with_env(CC: "cc", CXX: "c++") { system "./make.bash" }
end

libexec.install Dir["*"]
bin.install_symlink Dir[libexec/"bin/go*"]

system bin/"go", "install", "std", "cmd"

# 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")

with_env(GOOS: "freebsd", GOARCH: "amd64") do
system bin/"go", "build", "hello.go"
end

(testpath/"hello_cgo.go").write <<~EOS
package main

/*
#include <stdlib.h>
#include <stdio.h>
void hello() { printf("%s\\n", "Hello from cgo!"); fflush(stdout); }
*/
import "C"

func main() {
C.hello()
}
EOS

# Try running a sample using cgo without CC or CXX set to ensure that the
# toolchain's default choice of compilers work
with_env(CC: nil, CXX: nil) do
assert_equal "Hello from cgo!\n", shell_output("#{bin}/go run hello_cgo.go")
end
end
end
2 changes: 1 addition & 1 deletion Formula/g/grafana-agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GrafanaAgent < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "e35c1ddd635a982b507cb0212a5f185b43f4f3624d0e0d230f1e8f6d719c686e"
end

depends_on "go" => :build
depends_on "go@1.21" => :build # use "go" again when https://github.com/grafana/agent/pull/6139 is released
depends_on "node" => :build
depends_on "yarn" => :build

Expand Down
2 changes: 1 addition & 1 deletion Formula/g/grafana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Grafana < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "9c8d77a8b68c8cf139b3406afc79ea4ed1c7985370fbb15c537275fe9129af56"
end

depends_on "go" => :build
depends_on "go@1.21" => :build # use "go" again when https://github.com/grafana/grafana/pull/82114 is released
depends_on "node" => :build
depends_on "yarn" => :build

Expand Down
2 changes: 1 addition & 1 deletion Formula/j/juicefs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Juicefs < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "4d0f01c6689b8a3ee1565cf80752214efd2e6fcd6a2edb429171bdfc440c04f5"
end

depends_on "go" => :build
depends_on "go@1.21" => :build # use "go" again when https://github.com/juicedata/juicefs/pull/4340 is released

def install
system "make"
Expand Down