Skip to content

Commit 310c75c

Browse files
committed
[email protected] 1.23.5 (new formula)
1 parent 5af9432 commit 310c75c

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

Formula/g/[email protected]

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
class GoAT123 < Formula
2+
desc "Open source programming language to build simple/reliable/efficient software"
3+
homepage "https://go.dev/"
4+
url "https://go.dev/dl/go1.23.5.src.tar.gz"
5+
mirror "https://fossies.org/linux/misc/go1.23.5.src.tar.gz"
6+
sha256 "a6f3f4bbd3e6bdd626f79b668f212fbb5649daf75084fb79b678a0ae4d97423b"
7+
license "BSD-3-Clause"
8+
9+
livecheck do
10+
url "https://go.dev/dl/?mode=json"
11+
regex(/^go[._-]?v?(1\.23(?:\.\d+)*)[._-]src\.t.+$/i)
12+
strategy :json do |json, regex|
13+
json.map do |release|
14+
next if release["stable"] != true
15+
next if release["files"].none? { |file| file["filename"].match?(regex) }
16+
17+
release["version"][/(\d+(?:\.\d+)+)/, 1]
18+
end
19+
end
20+
end
21+
22+
keg_only :versioned_formula
23+
24+
depends_on "go" => :build
25+
26+
def install
27+
cd "src" do
28+
ENV["GOROOT_FINAL"] = libexec
29+
# Set portable defaults for CC/CXX to be used by cgo
30+
with_env(CC: "cc", CXX: "c++") { system "./make.bash" }
31+
end
32+
33+
libexec.install Dir["*"]
34+
bin.install_symlink Dir[libexec/"bin/go*"]
35+
36+
system bin/"go", "install", "std", "cmd"
37+
38+
# Remove useless files.
39+
# Breaks patchelf because folder contains weird debug/test files
40+
rm_r(libexec/"src/debug/elf/testdata")
41+
# Binaries built for an incompatible architecture
42+
rm_r(libexec/"src/runtime/pprof/testdata")
43+
end
44+
45+
test do
46+
(testpath/"hello.go").write <<~GO
47+
package main
48+
49+
import "fmt"
50+
51+
func main() {
52+
fmt.Println("Hello World")
53+
}
54+
GO
55+
56+
# Run go fmt check for no errors then run the program.
57+
# This is a a bare minimum of go working as it uses fmt, build, and run.
58+
system bin/"go", "fmt", "hello.go"
59+
assert_equal "Hello World\n", shell_output("#{bin}/go run hello.go")
60+
61+
with_env(GOOS: "freebsd", GOARCH: "amd64") do
62+
system bin/"go", "build", "hello.go"
63+
end
64+
65+
(testpath/"hello_cgo.go").write <<~GO
66+
package main
67+
68+
/*
69+
#include <stdlib.h>
70+
#include <stdio.h>
71+
void hello() { printf("%s\\n", "Hello from cgo!"); fflush(stdout); }
72+
*/
73+
import "C"
74+
75+
func main() {
76+
C.hello()
77+
}
78+
GO
79+
80+
# Try running a sample using cgo without CC or CXX set to ensure that the
81+
# toolchain's default choice of compilers work
82+
with_env(CC: nil, CXX: nil) do
83+
assert_equal "Hello from cgo!\n", shell_output("#{bin}/go run hello_cgo.go")
84+
end
85+
end
86+
end

0 commit comments

Comments
 (0)