projects/guix·blob python-team · refs

1082 lines · 51.9 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016-2025 Efraim Flashner <[email protected]>
3;;; Copyright © 2016 Matthew Jordan <[email protected]>
4;;; Copyright © 2016 Andy Wingo <[email protected]>
5;;; Copyright © 2016, 2019, 2021 Ludovic Courtès <[email protected]>
6;;; Copyright © 2016, 2017 Petter <[email protected]>
7;;; Copyright © 2016, 2017, 2018, 2019, 2020 Leo Famulari <[email protected]>
8;;; Copyright © 2017 Sergei Trofimovich <[email protected]>
9;;; Copyright © 2017 Alex Vong <[email protected]>
10;;; Copyright © 2018, 2021 Tobias Geerinckx-Rice <[email protected]>
11;;; Copyright © 2018 Christopher Baines <[email protected]>
12;;; Copyright © 2018 Tomáš Čech <[email protected]>
13;;; Copyright © 2018 Pierre-Antoine Rouby <[email protected]>
14;;; Copyright © 2018 Pierre Neidhardt <[email protected]>
15;;; Copyright © 2018, 2019, 2020, 2023, 2024 Katherine Cox-Buday <[email protected]>
16;;; Copyright © 2019 Giovanni Biscuolo <[email protected]>
17;;; Copyright © 2019, 2020 Alex Griffin <[email protected]>
18;;; Copyright © 2019, 2020, 2021 Arun Isaac <[email protected]>
19;;; Copyright © 2020 Jack Hill <[email protected]>
20;;; Copyright © 2020 Jakub Kądziołka <[email protected]>
21;;; Copyright © 2020 Nicolas Goaziou <[email protected]>
22;;; Copyright © 2020 Ryan Prior <[email protected]>
23;;; Copyright © 2020 Marius Bakke <[email protected]>
24;;; Copyright © 2020 raingloom <[email protected]>
25;;; Copyright © 2020 Martin Becze <[email protected]>
26;;; Copyright © 2021, 2022 Ricardo Wurmus <[email protected]>
27;;; Copyright © 2021 Guillaume Le Vaillant <[email protected]>
28;;; Copyright © 2021-2026 Sharlatan Hellseher <[email protected]>
29;;; Copyright © 2021 Sarah Morgensen <[email protected]>
30;;; Copyright © 2021 Raghav Gururajan <[email protected]>
31;;; Copyright © 2021 jgart <[email protected]>
32;;; Copyright © 2021 Bonface Munyoki Kilyungi <[email protected]>
33;;; Copyright © 2021 Chadwain Holness <[email protected]>
34;;; Copyright © 2021 Philip McGrath <[email protected]>
35;;; Copyright © 2021 Lu Hui <[email protected]>
36;;; Copyright © 2022 Pier-Hugues Pellerin <[email protected]>
37;;; Copyright © 2022 muradm <[email protected]>
38;;; Copyright © 2022 Dhruvin Gandhi <[email protected]>
39;;; Copyright © 2022, 2023 Nicolas Graves <[email protected]>
40;;; Copyright © 2022 ( <[email protected]>
41;;; Copyright © 2022 Christopher Howard <[email protected]>
42;;; Copyright © 2023 Hilton Chain <[email protected]>
43;;; Copyright © 2023 Timo Wilken <[email protected]>
44;;; Copyright © 2023, 2024 Artyom V. Poptsov <[email protected]>
45;;; Copyright © 2023 Clément Lassieur <[email protected]>
46;;; Copyright © 2024 Troy Figiel <[email protected]>
47;;; Copyright © 2024 Greg Hogan <[email protected]>
48;;; Copyright © 2024 Brennan Vincent <[email protected]>
49;;; Copyright © 2024 André Batista <[email protected]>
50;;; Copyright © 2024 Janneke Nieuwenhuizen <[email protected]>
51;;; Copyright © 2026 Ethan Blanton <[email protected]>
52;;;
53;;; This file is part of GNU Guix.
54;;;
55;;; GNU Guix is free software; you can redistribute it and/or modify it
56;;; under the terms of the GNU General Public License as published by
57;;; the Free Software Foundation; either version 3 of the License, or (at
58;;; your option) any later version.
59;;;
60;;; GNU Guix is distributed in the hope that it will be useful, but
61;;; WITHOUT ANY WARRANTY; without even the implied warranty of
62;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63;;; GNU General Public License for more details.
64;;;
65;;; You should have received a copy of the GNU General Public License
66;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
67
68(define-module (gnu packages golang)
69 #:use-module ((guix licenses) #:prefix license:)
70 #:use-module (guix utils)
71 #:use-module (guix gexp)
72 #:use-module (guix memoization)
73 #:use-module ((guix build utils) #:select (alist-replace))
74 #:use-module (guix download)
75 #:use-module (guix git-download)
76 #:use-module (guix packages)
77 #:use-module (guix build-system gnu)
78 #:use-module (guix build-system go)
79 #:use-module (gnu packages)
80 #:use-module (gnu packages admin)
81 #:use-module (gnu packages base)
82 #:use-module ((gnu packages bootstrap) #:select (glibc-dynamic-linker))
83 #:use-module (gnu packages check)
84 #:use-module (gnu packages gcc)
85 #:use-module (gnu packages glib)
86 #:use-module (gnu packages linux)
87 #:use-module (gnu packages pcre)
88 #:use-module (gnu packages perl)
89 #:use-module (gnu packages pkg-config)
90 #:use-module (ice-9 match)
91 #:use-module (srfi srfi-1))
92
93;; According to https://go.dev/doc/install/gccgo, gccgo-11 includes a complete
94;; implementation of go-1.16 and gccgo-12 includes a complete implementation of
95;; go-1.18. Starting with go-1.5 go cannot be built without an existing
96;; installation of go, so we need to use go-1.4 or gccgo. For architectures which
97;; are not supported with go-1.4 we use a version of gccgo to bootstrap them.
98;;
99;; The minimum version of Go required depends on the target version of Go:
100;;
101;; Go <= 1.4: a C toolchain.
102;; 1.5 <= Go <= 1.19: a Go 1.4 compiler.
103;; 1.20 <= Go <= 1.21: a Go 1.17 compiler.
104;; 1.22 <= Go <= 1.23: a Go 1.20 compiler.
105;;
106;; Going forward, Go version 1.N will require a Go 1.M compiler, where M is
107;; N-2 rounded down to an even number.
108;; Example: Go 1.24 and 1.25 require Go 1.22.
109;; See: <https://go.dev/doc/install/source>.
110
111(define-public go-1.4
112 (package
113 (properties '((hidden? . #t))) ;for bootstrap only
114 (name "go")
115 ;; The C-language bootstrap of Go:
116 ;; https://golang.org/doc/install/source#go14
117 (version "1.4-bootstrap-20171003")
118 (source (origin
119 (method url-fetch)
120 (uri (string-append "https://storage.googleapis.com/golang/"
121 name version ".tar.gz"))
122 (sha256
123 (base32
124 "0liybk5z00hizsb5ypkbhqcawnwwa6mkwgvjjg4y3jm3ndg5pzzl"))))
125 (build-system gnu-build-system)
126 (outputs '("out"
127 "doc"
128 "tests"))
129 (arguments
130 `(#:modules ((ice-9 match)
131 (guix build gnu-build-system)
132 (guix build utils)
133 (srfi srfi-1))
134 #:tests? #f ; Tests are run by the all.bash script.
135 #:phases
136 (modify-phases %standard-phases
137 (delete 'configure)
138 (add-after 'patch-generated-file-shebangs 'chdir
139 (lambda _
140 (chdir "src")
141 #t))
142 (add-before 'build 'prebuild
143 (lambda* (#:key inputs outputs #:allow-other-keys)
144 (let* ((gcclib (string-append (assoc-ref inputs "gcc:lib") "/lib"))
145 (ld (string-append (assoc-ref inputs "libc") "/lib"))
146 (loader (car (find-files ld "^ld-linux.+")))
147 (net-base (assoc-ref inputs "net-base"))
148 (tzdata-path
149 (string-append (assoc-ref inputs "tzdata") "/share/zoneinfo"))
150 (output (assoc-ref outputs "out")))
151
152 ;; Removing net/ tests, which fail when attempting to access
153 ;; network resources not present in the build container.
154 (for-each delete-file
155 '("net/multicast_test.go" "net/parse_test.go"
156 "net/port_test.go"))
157
158 ;; Add libgcc to the RUNPATH.
159 (substitute* "cmd/go/build.go"
160 (("cgoldflags := \\[\\]string\\{\\}")
161 (string-append "cgoldflags := []string{"
162 "\"-rpath=" gcclib "\"}"))
163 (("ldflags := buildLdflags")
164 (string-append
165 "ldflags := buildLdflags\n"
166 "ldflags = append(ldflags, \"-r\")\n"
167 "ldflags = append(ldflags, \"" gcclib "\")\n")))
168
169 (substitute* "os/os_test.go"
170 (("/usr/bin") (getcwd))
171 (("/bin/pwd") (which "pwd")))
172
173 ;; Disable failing tests: these tests attempt to access
174 ;; commands or network resources which are neither available or
175 ;; necessary for the build to succeed.
176 (for-each
177 (match-lambda
178 ((file regex)
179 (substitute* file
180 ((regex all before test_name)
181 (string-append before "Disabled" test_name)))))
182 '(("net/net_test.go" "(.+)(TestShutdownUnix.+)")
183 ("net/dial_test.go" "(.+)(TestDialTimeout.+)")
184 ("os/os_test.go" "(.+)(TestHostname.+)")
185 ("time/format_test.go" "(.+)(TestParseInSydney.+)")
186
187 ;; XXX: This test fails with tzdata 2020b and newer. Later
188 ;; Go releases work fine, so just disable this for the
189 ;; bootstrap Go.
190 ("time/example_test.go" "(.+)(ExampleParseInLocation.+)")
191
192 ("os/exec/exec_test.go" "(.+)(TestEcho.+)")
193 ("os/exec/exec_test.go" "(.+)(TestCommandRelativeName.+)")
194 ("os/exec/exec_test.go" "(.+)(TestCatStdin.+)")
195 ("os/exec/exec_test.go" "(.+)(TestCatGoodAndBadFile.+)")
196 ("os/exec/exec_test.go" "(.+)(TestExitStatus.+)")
197 ("os/exec/exec_test.go" "(.+)(TestPipes.+)")
198 ("os/exec/exec_test.go" "(.+)(TestStdinClose.+)")
199 ("syscall/syscall_unix_test.go" "(.+)(TestPassFD\\(.+)")
200 ("os/exec/exec_test.go" "(.+)(TestExtraFiles.+)")))
201
202 (substitute* "net/lookup_unix.go"
203 (("/etc/protocols") (string-append net-base "/etc/protocols")))
204 (substitute* "time/zoneinfo_unix.go"
205 (("/usr/share/zoneinfo/") tzdata-path))
206 (substitute* (find-files "cmd" "asm.c")
207 (("/lib/ld-linux.*\\.so\\.[0-9]") loader))
208 #t)))
209
210 (replace 'build
211 (lambda* (#:key inputs outputs #:allow-other-keys)
212 ;; FIXME: Some of the .a files are not bit-reproducible.
213 (let* ((output (assoc-ref outputs "out")))
214 (setenv "CC" (which "gcc"))
215 (setenv "GOOS" "linux")
216 (setenv "GOROOT" (dirname (getcwd)))
217 (setenv "GOROOT_FINAL" output)
218 (setenv "GO14TESTS" "1")
219 (invoke "sh" "all.bash"))))
220
221 (replace 'install
222 (lambda* (#:key outputs inputs #:allow-other-keys)
223 (let* ((output (assoc-ref outputs "out"))
224 (doc_out (assoc-ref outputs "doc"))
225 (bash (string-append (assoc-ref inputs "bash") "bin/bash"))
226 (docs (string-append doc_out "/share/doc/" ,name "-" ,version))
227 (tests (string-append
228 (assoc-ref outputs "tests") "/share/" ,name "-" ,version)))
229 (mkdir-p tests)
230 (copy-recursively "../test" (string-append tests "/test"))
231 (delete-file-recursively "../test")
232 (mkdir-p docs)
233 (copy-recursively "../api" (string-append docs "/api"))
234 (delete-file-recursively "../api")
235 (copy-recursively "../doc" (string-append docs "/doc"))
236 (delete-file-recursively "../doc")
237
238 (for-each (lambda (file)
239 (let ((file (string-append "../" file)))
240 (install-file file docs)
241 (delete-file file)))
242 '("README" "CONTRIBUTORS" "AUTHORS" "PATENTS"
243 "LICENSE" "VERSION" "robots.txt"))
244 (copy-recursively "../" output)
245 #t))))))
246 (inputs
247 `(("tzdata" ,tzdata)
248 ("pcre" ,pcre)
249 ("gcc:lib" ,gcc "lib")))
250 (native-inputs
251 (list pkg-config which net-base perl))
252
253 (home-page "https://go.dev/")
254 (synopsis "Compiler and libraries for Go, a statically-typed language")
255 (description "Go, also commonly referred to as golang, is an imperative
256programming language designed primarily for systems programming. Go is a
257compiled, statically typed language in the tradition of C and C++, but adds
258garbage collection, various safety features, and concurrent programming features
259in the style of communicating sequential processes (@dfn{CSP}).")
260 (supported-systems '("x86_64-linux" "i686-linux" "armhf-linux"))
261 (license license:bsd-3)))
262
263;; https://github.com/golang/go/wiki/MinimumRequirements#microarchitecture-support
264(define %go-1.17-arm-micro-architectures
265 (list "armv5" "armv6" "armv7"))
266
267(define %go-1.17-powerpc64le-micro-architectures
268 (list "power8" "power9"))
269
270(define-public go-1.17
271 (package
272 (name "go")
273 (version "1.17.13")
274 (source
275 (origin
276 (method git-fetch)
277 (uri (git-reference
278 (url "https://github.com/golang/go")
279 (commit (string-append "go" version))))
280 (file-name (git-file-name name version))
281 (sha256
282 (base32
283 "05m8gr050kagvn22lfnjrgms03l5iphd1m4v6z7yqlhn9gdp912d"))))
284 (outputs '("out" "tests")) ; 'tests' contains distribution tests.
285 (build-system gnu-build-system)
286 (arguments
287 `(#:modules ((ice-9 match)
288 (guix build gnu-build-system)
289 (guix build utils))
290 ;; TODO: Disable the test(s) in misc/cgo/test/cgo_test.go
291 ;; that cause segfaults in the test suite.
292 #:tests? ,(not (or (target-arm32?) (target-riscv64?)))
293 #:phases
294 (modify-phases %standard-phases
295 (replace 'configure
296 (lambda* (#:key inputs outputs #:allow-other-keys)
297 (let ((output (assoc-ref outputs "out"))
298 (loader (string-append (assoc-ref inputs "libc")
299 ,(glibc-dynamic-linker))))
300 (setenv "GOOS" "linux")
301 (setenv "GO_LDSO" loader)
302 (setenv "GOROOT" (getcwd))
303 (setenv "GOROOT_FINAL" (string-append output "/lib/go"))
304 (setenv "GOGC" "400")
305 (setenv "GOCACHE" "/tmp/go-cache"))))
306
307 ;; Time bomb in TLS tests: "Most of the test certificates
308 ;; (e.g. testRSACertificate, testRSACertificateIssuer,
309 ;; testRSA2048CertificateIssuer) have a not after of Jan 1
310 ;; 00:00:00 2025 GMT."
311 ;; https://github.com/golang/go/issues/71077
312 ;; https://github.com/golang/go/issues/71103
313 ;; https://github.com/golang/go/issues/71104
314 (add-after 'unpack 'skip-crypto-tls-tests
315 (lambda _
316 (substitute* (list "src/crypto/tls/handshake_client_test.go"
317 "src/crypto/tls/handshake_server_test.go")
318 (("TestVerifyConnection.*" all)
319 (string-append all "\n t.Skip(\"golang.org/issue/71077\")\n"))
320 (("TestResumptionKeepsOCSPAndSCT.*" all)
321 (string-append all "\n t.Skip(\"golang.org/issue/71077\")\n"))
322 (("TestCrossVersionResume.*" all)
323 (string-append all "\n t.Skip(\"golang.org/issue/71077\")\n")))))
324
325 (add-after 'unpack 'patch-source
326 (lambda* (#:key inputs outputs #:allow-other-keys)
327 (let* ((net-base (assoc-ref inputs "net-base"))
328 (tzdata-path (string-append (assoc-ref inputs "tzdata")
329 "/share/zoneinfo")))
330 ;; XXX: Remove when #49729 is merged?
331 (for-each make-file-writable (find-files "src"))
332
333 ;; Having the patch in the 'patches' field of <origin> breaks
334 ;; the 'TestServeContent' test due to the fact that
335 ;; timestamps are reset. Thus, apply it from here.
336 (invoke "patch" "-p1" "--force" "-i"
337 (assoc-ref inputs "go-skip-gc-test.patch"))
338 (invoke "patch" "-p1" "--force" "-i"
339 (assoc-ref inputs "go-fix-script-tests.patch"))
340
341 (substitute* "src/os/os_test.go"
342 (("/usr/bin") (getcwd))
343 (("/bin/sh") (which "sh")))
344
345 (substitute* "src/cmd/go/testdata/script/cgo_path_space.txt"
346 (("/bin/sh") (which "sh")))
347
348 ;; fix shebang for testar script
349 ;; note the target script is generated at build time.
350 (substitute* "misc/cgo/testcarchive/carchive_test.go"
351 (("/usr/bin/env bash") (which "bash")))
352
353 (substitute* "src/net/lookup_unix.go"
354 (("/etc/protocols")
355 (string-append net-base "/etc/protocols")))
356 (substitute* "src/net/port_unix.go"
357 (("/etc/services")
358 (string-append net-base "/etc/services")))
359 (substitute* "src/time/zoneinfo_unix.go"
360 (("/usr/share/zoneinfo/") tzdata-path)))))
361 (add-after 'unpack 'patch-gcc:lib
362 (lambda* (#:key inputs #:allow-other-keys)
363 (let* ((gcclib (string-append (assoc-ref inputs "gcc:lib") "/lib")))
364 ;; Add libgcc to runpath
365 (substitute* "src/cmd/link/internal/ld/lib.go"
366 (("!rpath.set") "true"))
367 (substitute* "src/cmd/go/internal/work/gccgo.go"
368 (("cgoldflags := \\[\\]string\\{\\}")
369 (string-append "cgoldflags := []string{"
370 "\"-Wl,-rpath=" gcclib "\""
371 "}"))
372 (("\"-lgcc_s\", ")
373 (string-append
374 "\"-Wl,-rpath=" gcclib "\", \"-lgcc_s\", ")))
375 (substitute* "src/cmd/go/internal/work/gc.go"
376 (("ldflags = setextld\\(ldflags, compiler\\)")
377 (string-append
378 "ldflags = setextld(ldflags, compiler)\n"
379 "ldflags = append(ldflags, \"-r\")\n"
380 "ldflags = append(ldflags, \"" gcclib "\")\n"))))))
381 ;; Backported from later versions of go to workaround 64k page sizes.
382 ,@(if (target-ppc64le?)
383 '((add-after 'unpack 'adjust-test-suite
384 (lambda _
385 (substitute* "misc/cgo/testshared/shared_test.go"
386 (("100000") "256000")))))
387 '())
388 (add-after 'patch-source 'disable-failing-tests
389 (lambda _
390 ;; Disable failing tests: these tests attempt to access
391 ;; commands or network resources which are neither available
392 ;; nor necessary for the build to succeed.
393 (for-each
394 (match-lambda
395 ((file test)
396 (let ((regex (string-append "^(func\\s+)(" test "\\()")))
397 (substitute* file
398 ((regex all before test_name)
399 (string-append before "Disabled" test_name))))))
400 '(("src/net/cgo_unix_test.go" "TestCgoLookupPort")
401 ("src/net/cgo_unix_test.go" "TestCgoLookupPortWithCancel")
402 ;; 127.0.0.1 doesn't exist
403 ("src/net/cgo_unix_test.go" "TestCgoLookupPTR")
404 ("src/net/cgo_unix_test.go" "TestCgoLookupPTRWithCancel")
405 ;; /etc/services doesn't exist
406 ("src/net/parse_test.go" "TestReadLine")
407 ;; The user's directory doesn't exist
408 ("src/os/os_test.go" "TestUserHomeDir")))
409
410 ;; These tests fail on aarch64-linux
411 (substitute* "src/cmd/dist/test.go"
412 (("t.registerHostTest\\(\"testsanitizers/msan.*") ""))))
413 (add-after 'patch-source 'enable-external-linking
414 (lambda _
415 ;; Invoke GCC to link any archives created with GCC (that is, any
416 ;; packages built using 'cgo'), because Go doesn't know how to
417 ;; handle the runpaths but GCC does. Use substitute* rather than
418 ;; a patch since these files are liable to change often.
419 ;;
420 ;; XXX: Replace with GO_EXTLINK_ENABLED=1 or similar when
421 ;; <https://github.com/golang/go/issues/31544> and/or
422 ;; <https://github.com/golang/go/issues/43525> are resolved.
423 (substitute* "src/cmd/link/internal/ld/config.go"
424 (("iscgo && externalobj") "iscgo"))
425 (substitute* '("src/cmd/nm/nm_cgo_test.go"
426 "src/cmd/dist/test.go")
427 (("^func.*?nternalLink\\(\\).*" all)
428 (string-append all "\n\treturn false\n")))))
429 (replace 'build
430 (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
431 (let* ((njobs (if parallel-build? (parallel-job-count) 1)))
432 (with-directory-excursion "src"
433 (setenv "GOMAXPROCS" (number->string njobs))
434 (invoke "sh" "make.bash" "--no-banner")))))
435 (replace 'check
436 (lambda* (#:key target (tests? (not target)) (parallel-tests? #t)
437 #:allow-other-keys)
438 (let* ((njobs (if parallel-tests? (parallel-job-count) 1)))
439 (when tests?
440 (with-directory-excursion "src"
441 (setenv "GOMAXPROCS" (number->string njobs))
442 (invoke "sh" "run.bash" "--no-rebuild"))))))
443 (add-before 'install 'unpatch-perl-shebangs
444 (lambda _
445 ;; Avoid inclusion of perl in closure by rewriting references
446 ;; to perl input in sourcecode generators and test scripts
447 (substitute* (cons "src/net/http/cgi/testdata/test.cgi"
448 (find-files "src" "\\.pl$"))
449 (("^#!.*") "#!/usr/bin/env perl\n"))))
450 (replace 'install
451 (lambda* (#:key outputs #:allow-other-keys)
452 ;; Notably, we do not install archives (180M), which Go will
453 ;; happily recompile quickly (and cache) if needed, almost
454 ;; surely faster than they could be substituted.
455 ;;
456 ;; The main motivation for pre-compiled archives is to use
457 ;; libc-linked `net' or `os' packages without a C compiler,
458 ;; but on Guix a C compiler is necessary to properly link the
459 ;; final binaries anyway. Many build flags also invalidate
460 ;; these pre-compiled archives, so in practice Go often
461 ;; recompiles them anyway.
462 ;;
463 ;; Upstream is also planning to no longer install these
464 ;; archives: <https://github.com/golang/go/issues/47257>
465 ;;
466 ;; When necessary, a custom pre-compiled library package can
467 ;; be created with `#:import-path "std"' and used with
468 ;; `-pkgdir'.
469 (let* ((out (assoc-ref outputs "out"))
470 (tests (assoc-ref outputs "tests")))
471 (for-each
472 (lambda (file)
473 (copy-recursively file (string-append out "/lib/go/" file)))
474 '("lib" "VERSION" "pkg/include" "pkg/tool"))
475
476 (for-each
477 (match-lambda
478 ((file dest output)
479 ;; Copy to output/dest and symlink from output/lib/go/file.
480 (let ((file* (string-append output "/lib/go/" file))
481 (dest* (string-append output "/" dest)))
482 (copy-recursively file dest*)
483 (mkdir-p (dirname file*))
484 (symlink (string-append "../../" dest) file*))))
485 `(("bin" "bin" ,out)
486 ("src" "share/go/src" ,out)
487 ("misc" "share/go/misc" ,out)
488 ("doc" "share/doc/go/doc" ,out)
489 ("api" "share/go/api" ,tests)
490 ("test" "share/go/test" ,tests))))))
491 (add-after 'install 'install-doc-files
492 (lambda* (#:key outputs #:allow-other-keys)
493 (let ((out (assoc-ref outputs "out")))
494 (for-each
495 (lambda (file)
496 (install-file file (string-append out "/share/doc/go")))
497 '("AUTHORS" "CONTRIBUTORS" "CONTRIBUTING.md" "PATENTS"
498 "README.md" "SECURITY.md"))))))))
499 (inputs
500 `(("tzdata" ,tzdata)
501 ("pcre" ,pcre)
502 ("gcc:lib" ,gcc "lib")))
503 (native-inputs
504 `(,@(if (member (%current-system) (package-supported-systems go-1.4))
505 `(("go" ,go-1.4))
506 `(("go" ,gccgo-12)))
507 ("go-skip-gc-test.patch" ,(search-patch "go-skip-gc-test.patch"))
508 ("go-fix-script-tests.patch" ,(search-patch "go-fix-script-tests.patch"))
509 ,@(package-native-inputs go-1.4)
510 ;; For plugin.test which requires "-fuse-ld=gold"
511 ,@(match (%current-system)
512 ((or "armhf-linux" "aarch64-linux")
513 `(("gold" ,binutils-gold)))
514 (_ `()))))
515 (home-page "https://go.dev/")
516 (synopsis "Compiler and libraries for Go, a statically-typed language")
517 (description "Go, also commonly referred to as golang, is an imperative
518programming language designed primarily for systems programming. Go is a
519compiled, statically typed language in the tradition of C and C++, but adds
520garbage collection, various safety features, and concurrent programming features
521in the style of communicating sequential processes (@dfn{CSP}).")
522 (supported-systems (fold delete %supported-systems
523 (list "powerpc-linux" "i586-gnu" "x86_64-gnu")))
524 (properties
525 `((hidden? . #t) ;for bootstrap only
526 (compiler-cpu-architectures
527 ("armhf" ,@%go-1.17-arm-micro-architectures)
528 ("powerpc64le" ,@%go-1.17-powerpc64le-micro-architectures))))
529 (license license:bsd-3)))
530
531(define %go-1.18-x86_64-micro-architectures
532 ;; GOAMD defaults to 'v1' so we match the default elsewhere.
533 (list "x86-64" "x86-64-v2" "x86-64-v3" "x86-64-v4"))
534
535(define-public go-1.20
536 (package
537 (inherit go-1.17)
538 (name "go")
539 (version "1.20.14")
540 (source (origin
541 (method git-fetch)
542 (uri (git-reference
543 (url "https://github.com/golang/go")
544 (commit (string-append "go" version))))
545 (file-name (git-file-name name version))
546 (sha256
547 (base32
548 "1aqhc23705q76dca3g0fzq98kxkhyq628s0811qgzgz4wmngsjfm"))))
549 (arguments
550 (substitute-keyword-arguments (package-arguments go-1.17)
551 ((#:parallel-tests? _ #t)
552 (not (target-riscv64?)))
553 ;; TODO: Disable the test(s) in misc/cgo/test/cgo_test.go
554 ;; that cause segfaults in the test suite.
555 ((#:tests? _ (not (%current-target-system)))
556 (and (not (%current-target-system))
557 (not (target-riscv64?))))
558 ((#:phases phases)
559 #~(modify-phases #$phases
560 (delete 'adjust-test-suite)
561 (replace 'patch-gcc:lib
562 (lambda* (#:key inputs #:allow-other-keys)
563 (let* ((gcclib (string-append (assoc-ref inputs "gcc:lib") "/lib")))
564 ;; Add libgcc to runpath
565 (substitute* "src/cmd/link/internal/ld/lib.go"
566 (("!rpath.set") "true"))
567 (substitute* "src/cmd/go/internal/work/gccgo.go"
568 (("cgoldflags := \\[\\]string\\{\\}")
569 (string-append "cgoldflags := []string{"
570 "\"-Wl,-rpath=" gcclib "\""
571 "}"))
572 (("\"-lgcc_s\", ")
573 (string-append
574 "\"-Wl,-rpath=" gcclib "\", \"-lgcc_s\", ")))
575 (substitute* "src/cmd/go/internal/work/gc.go"
576 (("ldflags, err := setextld\\(ldflags, compiler\\)")
577 (string-append
578 "ldflags, err := setextld(ldflags, compiler)\n"
579 "ldflags = append(ldflags, \"-r\")\n"
580 "ldflags = append(ldflags, \"" gcclib "\")\n"))))))
581 ;; These are recurring test failures, depending on having a new
582 ;; enough version of gccgo. gccgo-12.2 fails with go-1.19.7.
583 ;; https://github.com/golang/go/issues/22224
584 ;; https://github.com/golang/go/issues/25324
585 (add-after 'unpack 'skip-TestGoPathShlibGccgo-tests
586 (lambda _
587 (substitute* "misc/cgo/testshared/shared_test.go"
588 (("TestGoPathShlibGccgo.*" all)
589 (string-append all "\n t.Skip(\"golang.org/issue/22224\")\n"))
590 (("TestTwoGopathShlibsGccgo.*" all)
591 (string-append all "\n t.Skip(\"golang.org/issue/22224\")\n")))))
592 (replace 'install-doc-files
593 (lambda _
594 (for-each (lambda (file)
595 (install-file file (string-append
596 #$output "/share/doc/go")))
597 '("CONTRIBUTING.md" "PATENTS" "README.md"
598 "SECURITY.md"))))
599 (add-after 'disable-failing-tests 'disable-more-tests
600 (lambda _
601 ;; Unclear why this test fails on x86_64.
602 (substitute* "misc/cgo/testsanitizers/asan_test.go"
603 ((".*arena_fail.*") "")
604 ((".*asan_global1_fail.*") ""))
605 ;; error while loading shared libraries: libgcc_s.so.1:
606 ;; cannot open shared object file: No such file or directory
607 (for-each delete-file
608 '("test/fixedbugs/bug514.go"
609 "test/fixedbugs/issue40954.go"
610 "test/fixedbugs/issue42032.go"
611 "test/fixedbugs/issue42076.go"
612 "test/fixedbugs/issue51733.go"))
613 #$@(cond
614 ((target-aarch64?)
615 ;; https://go-review.googlesource.com/c/go/+/151303
616 ;; This test is known buggy on aarch64 and is enabled and
617 ;; disabled upstream with some regularity.
618 #~((substitute* "src/plugin/plugin_test.go"
619 (("package plugin_test")
620 (string-append "// +build !linux linux,!arm64\n\n"
621 "package plugin_test")))
622 ;; collect2: fatal error: cannot find ‘ld’
623 (substitute* "src/cmd/dist/test.go"
624 ((".*testcshared.*") "")
625 ((".*testshared.*") ""))))
626 ((target-arm32?)
627 ;; https://go-review.googlesource.com/c/go/+/151303
628 ;; This test is known buggy on aarch64 so we disable
629 ;; it on armhf also since we emulate armhf on aarch64.
630 #~((substitute* "src/plugin/plugin_test.go"
631 (("package plugin_test")
632 (string-append "// +build !linux linux,!arm\n\n"
633 "package plugin_test")))
634 ;; collect2: fatal error: cannot find ‘ld’
635 (substitute* "src/cmd/dist/test.go"
636 ((".*testcshared.*") "")
637 ((".*testshared.*") ""))))
638 ((target-riscv64?)
639 #~((substitute* "src/runtime/lockrank_test.go"
640 (("TestLockRankGenerated.*" all)
641 (string-append
642 all "\n "
643 "t.Skip(\"golang.org/issue/22224\")\n")))))
644 (else #~()))))))))
645 (native-inputs
646 ;; Go 1.20 and later requires Go 1.17 as the bootstrap toolchain.
647 ;; See 'src/cmd/dist/notgo117.go' in the source code distribution,
648 ;; as well as the upstream discussion of this topic:
649 ;; https://go.dev/issue/44505
650 ;; We continue to use gccgo-12 since it provides go-1.18.
651 ;; We remove gold since it causes test failures on aarch64-linux.
652 (if (member (%current-system) (package-supported-systems go-1.4))
653 (alist-replace "go" (list go-1.17) (package-native-inputs go-1.17))
654 (alist-delete "gold" (package-native-inputs go-1.17))))
655 (properties
656 `((hidden? . #t) ;for bootstrap only
657 (compiler-cpu-architectures
658 ("armhf" ,@%go-1.17-arm-micro-architectures)
659 ("powerpc64le" ,@%go-1.17-powerpc64le-micro-architectures)
660 ("x86_64" ,@%go-1.18-x86_64-micro-architectures))))))
661
662(define-public go-1.22
663 (package
664 (inherit go-1.20)
665 (name "go")
666 (version "1.22.12")
667 (source
668 (origin
669 (method git-fetch)
670 (uri (git-reference
671 (url "https://github.com/golang/go")
672 (commit (string-append "go" version))))
673 (file-name (git-file-name name version))
674 (sha256
675 (base32 "0f0fr92z3l3szmxf3wvh20w1sqayvd927gawdp5d44cc44pd6c0n"))))
676 (arguments
677 (substitute-keyword-arguments (package-arguments go-1.20)
678 ((#:parallel-tests? _ #t)
679 (or (not (target-riscv64?))
680 (not (target-arm32?))))
681 ((#:phases phases)
682 #~(modify-phases #$phases
683 ;; Source patching phases are broken up into discrete steps to allow
684 ;; future versions to discard individual phases without having to
685 ;; discard all source patching.
686 (delete 'skip-TestGoPathShlibGccgo-tests)
687 (delete 'patch-source)
688 (add-after 'unpack 'patch-os-tests
689 (lambda _
690 (substitute* "src/os/os_test.go"
691 (("/usr/bin") (getcwd))
692 (("/bin/sh") (which "sh")))))
693
694 (add-after 'unpack 'apply-patches
695 (lambda* (#:key inputs #:allow-other-keys)
696 ;; Having the patch in the 'patches' field of <origin> breaks
697 ;; the 'TestServeContent' test due to the fact that timestamps
698 ;; are reset. Thus, apply it from here.
699 (invoke "patch" "-p1" "--force" "-i"
700 (assoc-ref inputs "go-fix-script-tests.patch"))))
701
702 (add-after 'unpack 'patch-src/net
703 (lambda* (#:key inputs #:allow-other-keys)
704 (let ((net-base (assoc-ref inputs "net-base")))
705 (substitute* "src/net/lookup_unix.go"
706 (("/etc/protocols")
707 (string-append net-base "/etc/protocols")))
708 (substitute* "src/net/port_unix.go"
709 (("/etc/services")
710 (string-append net-base "/etc/services"))))))
711
712 (add-after 'unpack 'patch-zoneinfo
713 (lambda* (#:key inputs #:allow-other-keys)
714 ;; Add the path to this specific version of tzdata's zoneinfo
715 ;; file to the top of the list to search. We don't want to
716 ;; replace any sources because it will affect how binaries
717 ;; compiled with this Go toolchain behave on non-guix
718 ;; platforms.
719 (substitute* "src/time/zoneinfo_unix.go"
720 (("var platformZoneSources.+" all)
721 (format #f "~a~%\"~a/share/zoneinfo\",~%"
722 all
723 (assoc-ref inputs "tzdata"))))))
724
725 (add-after 'unpack 'patch-cmd/go/testdata/script
726 (lambda _
727 (substitute* "src/cmd/go/testdata/script/cgo_path_space.txt"
728 (("/bin/sh") (which "sh")))))
729
730 (add-after 'unpack 'remove-failing-test
731 (lambda _
732 ;; This test fails with newer gcc's
733 ;; https://github.com/golang/go/issues/57691
734 (substitute* "src/cmd/cgo/internal/testsanitizers/asan_test.go"
735 ((".*arena_fail.*") ""))))
736
737 (add-after 'enable-external-linking 'enable-external-linking-1.21
738 (lambda _
739 ;; Invoke GCC to link any archives created with GCC (that is,
740 ;; any packages built using 'cgo'), because Go doesn't know
741 ;; how to handle the runpaths but GCC does. Use substitute*
742 ;; rather than a patch since these files are liable to change
743 ;; often.
744 ;;
745 ;; XXX: Replace with GO_EXTLINK_ENABLED=1 or similar when
746 ;; <https://github.com/golang/go/issues/31544> and/or
747 ;; <https://github.com/golang/go/issues/43525> are resolved.
748 (substitute* "src/cmd/link/internal/ld/config.go"
749 (("\\(iscgo && \\(.+\\)") "iscgo"))
750 (substitute* "src/internal/testenv/testenv.go"
751 (("!CanInternalLink.+") "true {\n"))
752 (substitute* "src/syscall/exec_linux_test.go"
753 (("testenv.MustHaveExecPath\\(t, \"whoami\"\\)")
754 "t.Skipf(\"no passwd file present\")"))))
755
756 (replace 'install
757 (lambda* (#:key outputs #:allow-other-keys)
758 ;; Notably, we do not install archives (180M), which Go will
759 ;; happily recompile quickly (and cache) if needed, almost
760 ;; surely faster than they could be substituted.
761 ;;
762 ;; The main motivation for pre-compiled archives is to use
763 ;; libc-linked `net' or `os' packages without a C compiler,
764 ;; but on Guix a C compiler is necessary to properly link the
765 ;; final binaries anyway. Many build flags also invalidate
766 ;; these pre-compiled archives, so in practice Go often
767 ;; recompiles them anyway.
768 ;;
769 ;; Upstream is also planning to no longer install these
770 ;; archives: <https://github.com/golang/go/issues/47257>.
771 ;;
772 ;; When necessary, a custom pre-compiled library package can
773 ;; be created with `#:import-path "std"' and used with
774 ;; `-pkgdir'.
775 ;;
776 ;; When moving files into place, any files that come from
777 ;; GOROOT should remain in GOROOT to continue functioning. If
778 ;; they need to be referenced from some other directory, they
779 ;; need to be symlinked from GOROOT. For more information,
780 ;; please see <https://github.com/golang/go/issues/61921>.
781 (let* ((out (assoc-ref outputs "out"))
782 (tests (assoc-ref outputs "tests")))
783 (for-each
784 (lambda (file)
785 (copy-recursively file (string-append out "/lib/go/" file)))
786 '("bin" "go.env" "lib" "VERSION" "pkg/include" "pkg/tool"))
787
788 (symlink "lib/go/bin" (string-append out "/bin"))
789
790 (for-each
791 (match-lambda
792 ((file dest output)
793 ;; Copy to output/dest and symlink from
794 ;; output/lib/go/file.
795 (let ((file* (string-append output "/lib/go/" file))
796 (dest* (string-append output "/" dest)))
797 (copy-recursively file dest*)
798 (mkdir-p (dirname file*))
799 (symlink (string-append "../../" dest) file*))))
800 `(("src" "share/go/src" ,out)
801 ("misc" "share/go/misc" ,out)
802 ("doc" "share/doc/go/doc" ,out)
803 ("api" "share/go/api" ,tests)
804 ("test" "share/go/test" ,tests))))))
805
806 ;; Some architectures need more time for the test suite.
807 #$@(if (or (target-riscv64?)
808 (target-arm?))
809 #~((add-after 'unpack 'extend-test-timeout
810 (lambda _
811 (setenv "GO_TEST_TIMEOUT_SCALE" "10"))))
812 #~())
813 (replace 'disable-more-tests
814 (lambda _
815 #$@(cond
816 ((target-aarch64?)
817 ;; https://go-review.googlesource.com/c/go/+/151303
818 ;; This test is known buggy on aarch64 and is enabled and
819 ;; disabled upstream with some regularity.
820 #~((substitute* "src/plugin/plugin_test.go"
821 (("package plugin_test")
822 (string-append "// +build !linux linux,!arm64\n\n"
823 "package plugin_test")))
824 ;; These tests "run too slowly".
825 (substitute* "src/go/printer/printer_test.go"
826 ((".*go2numbers\\.input.*") "")
827 ((".*generics\\.input.*") "")
828 ((".*gobuild1\\.input.*") ""))))
829 (else (list #t)))))
830 (replace 'unpatch-perl-shebangs
831 (lambda _
832 ;; Avoid inclusion of perl in closure by rewriting references
833 ;; to perl input in sourcecode generators and test scripts
834 (substitute* (find-files "src" "\\.pl$")
835 (("^#!.*")
836 "#!/usr/bin/env perl\n"))))
837 (add-after 'unpack 'remove-flakey-thread-sanitizer-tests
838 (lambda _
839 ;; These tests have been identified as flakey:
840 ;; https://github.com/golang/go/issues/66427
841 (substitute* "src/cmd/cgo/internal/testsanitizers/tsan_test.go"
842 ((".*tsan1[34].*") ""))))))))
843 (native-inputs
844 ;; Go 1.22 and later requires Go 1.20 as the bootstrap toolchain.
845 (alist-replace "go" (list go-1.20) (package-native-inputs go-1.20)))))
846
847(define %go-1.23-arm64-micro-architectures
848 ;; https://go.dev/wiki/MinimumRequirements#arm64
849 ;; Allowed values are v8.{0-9} and v9.{0-5}. This may be followed by an option
850 ;; specifying extensions implemented by target hardware. Valid options are
851 ;; ,lse and ,crypto.
852 ;; Match Guix's specifications and then rewrite in (guix transformations).
853 (append (map (lambda (suffix) (string-append "armv8" suffix "-a"))
854 '("" ".1" ".2" ".3" ".4" ".5" ".6" ".7" ".8" ".9"))
855 (map (lambda (suffix) (string-append "armv9" suffix "-a"))
856 '("" ".1" ".2" ".3" ".4" ".5"))))
857
858(define %go-1.23-riscv64-micro-architectures
859 '("rva20u64" "rva22u64"))
860
861(define-public go-1.24
862 (package
863 (inherit go-1.22)
864 (name "go")
865 (version "1.24.13")
866 (source
867 (origin
868 (method git-fetch)
869 (uri (git-reference
870 (url "https://github.com/golang/go")
871 (commit (string-append "go" version))))
872 (file-name (git-file-name name version))
873 (sha256
874 (base32 "1w4yip0cbfs845655j2kflsww4dkzm3cqhlg8jqxkl2gxia98sf6"))))
875 (arguments
876 (substitute-keyword-arguments (package-arguments go-1.22)
877 ((#:phases phases)
878 #~(modify-phases #$phases
879 (replace 'disable-more-tests
880 (lambda _
881 #$@(cond
882 ((target-aarch64?)
883 ;; https://go-review.googlesource.com/c/go/+/151303
884 ;; This test is known buggy on aarch64 and is enabled and
885 ;; disabled upstream with some regularity.
886 #~((substitute* "src/plugin/plugin_test.go"
887 (("package plugin_test")
888 (string-append "// +build !linux linux,!arm64\n\n"
889 "package plugin_test")))))
890 ((target-arm32?)
891 ;; This test fails when run on aarch64-linux.
892 #~((substitute* "src/cmd/link/internal/ld/elf_test.go"
893 (("TestElfBindNow.*" all)
894 (string-append
895 all
896 " if runtime.GOARCH == \"arm\" {\n"
897 " t.Skipf(\"skipping; flaky on armhf\")\n"
898 " }\n")))))
899 (else (list #t)))))))))
900 (native-inputs
901 ;; Go 1.24 and later requires Go 1.22+ as the bootstrap toolchain.
902 (alist-replace "go" (list go-1.22) (package-native-inputs go-1.22)))
903 (properties
904 `((hidden? . #t) ;for bootstrap only
905 (compiler-cpu-architectures
906 ("aarch64" ,@%go-1.23-arm64-micro-architectures)
907 ("armhf" ,@%go-1.17-arm-micro-architectures)
908 ("powerpc64le" ,@%go-1.17-powerpc64le-micro-architectures)
909 ("riscv64" ,@%go-1.23-riscv64-micro-architectures)
910 ("x86_64" ,@%go-1.18-x86_64-micro-architectures))))))
911
912(define %go-1.25-riscv64-micro-architectures
913 '("rva20u64" "rva22u64" "rva23u64"))
914
915(define-public go-1.25
916 (package
917 (inherit go-1.24)
918 (name "go")
919 (version "1.25.12")
920 (source
921 (origin
922 (method git-fetch)
923 (uri (git-reference
924 (url "https://github.com/golang/go")
925 (commit (string-append "go" version))))
926 (file-name (git-file-name name version))
927 (sha256
928 (base32 "13191v8vixwf9a1yrn7hz828xfgdgm5dxx4vp0h4s0bzl4rzjn32"))))
929 (arguments
930 (substitute-keyword-arguments (package-arguments go-1.24)
931 ((#:phases phases)
932 #~(modify-phases #$phases
933 ;; There is no real discussion on the issue among humans, a lot
934 ;; of gopherbot updates and it's closed without final resolution.
935 ;; https://github.com/golang/go/issues/73977
936 (add-after 'unpack 'skip-TestSynctest-tests
937 (lambda _
938 (substitute* "src/runtime/synctest_test.go"
939 (("TestSynctest\\(.*" all)
940 (string-append all "\n t.Skip(\"golang.org/issue/73977\")\n")))))
941 (add-after 'unpack 'remove-testscript-mod_get_fips140_issue73649.txt
942 (lambda _
943 ;; vcs-test.golang.org rerouted to http://127.0.0.1:46381
944 ;; https://vcs-test.golang.org rerouted to https://127.0.0.1:44403
945 ;; go test proxy running at GOPROXY=http://127.0.0.1:40005/mod
946 ;; 2026/07/17 10:05:01 http: TLS handshake error from 127.0.0.1:33040: EOF
947 (delete-file "src/cmd/go/testdata/script/mod_get_fips140_issue73649.txt")))
948 #$@(if (target-aarch64?)
949 '((add-after 'unpack 'skip-shaky-tests-on-aarch64-system
950 (lambda _
951 (substitute* "src/net/mptcpsock_linux_test.go"
952 ;; Kernel specific <2024-08-02>
953 ;; https://github.com/golang/go/issues/68717
954 (("TestMultiPathTCP\\(.*" all)
955 (string-append all "\n t.Skip(\"golang.org/issue/68717\")\n")))
956 (substitute* "src/sync/atomic/atomic_test.go"
957 ;; QEMU aarch64 emulation related <2021-12-15>
958 ;; https://github.com/golang/go/issues/50188
959 (("TestStoreLoadSeqCst.*" all)
960 (string-append all "\n t.Skip(\"golang.org/issue/50188\")\n")))
961 (substitute* "src/syscall/syscall_ptrace_test.go"
962 ;; Shaky <2025-10-01> https://github.com/golang/go/issues/75720
963 (("TestExecPtrace\\(.*" all)
964 (string-append all "\n t.Skip(\"golang.org/issue/75720\")\n"))))))
965 '())))))
966 (properties
967 `((compiler-cpu-architectures
968 ("aarch64" ,@%go-1.23-arm64-micro-architectures)
969 ("armhf" ,@%go-1.17-arm-micro-architectures)
970 ("powerpc64le" ,@%go-1.17-powerpc64le-micro-architectures)
971 ("riscv64" ,@%go-1.25-riscv64-micro-architectures)
972 ("x86_64" ,@%go-1.18-x86_64-micro-architectures))))))
973
974(define-public go-1.26
975 (package
976 (inherit go-1.24)
977 (name "go")
978 (version "1.26.8")
979 (source
980 (origin
981 (method git-fetch)
982 (uri (git-reference
983 (url "https://github.com/golang/go")
984 (commit (string-append "go" version))))
985 (file-name (git-file-name name version))
986 (sha256
987 (base32 "0yaqgfbn03i65wr1a326m4kalqfqmp0bp7llkrfd04g96lxi6j44"))))
988 (arguments
989 (substitute-keyword-arguments arguments
990 ((#:phases phases)
991 #~(modify-phases #$phases
992 (add-after 'unpack 'remove-testscript-mod_get_fips140_issue73649.txt
993 (lambda _
994 ;; vcs-test.golang.org rerouted to http://127.0.0.1:46381
995 ;; https://vcs-test.golang.org rerouted to https://127.0.0.1:44403
996 ;; go test proxy running at GOPROXY=http://127.0.0.1:40005/mod
997 ;; 2026/07/17 10:05:01 http: TLS handshake error from 127.0.0.1:33040: EOF
998 (delete-file "src/cmd/go/testdata/script/mod_get_fips140_issue73649.txt")))
999 ;; There is no real discussion on the issue among humans, a lot
1000 ;; of gopherbot updates and it's closed without final resolution.
1001 ;; https://github.com/golang/go/issues/73977
1002 (add-after 'unpack 'skip-TestSynctest-tests
1003 (lambda _
1004 (substitute* "src/runtime/synctest_test.go"
1005 (("TestSynctest\\(.*" all)
1006 (string-append all "\n t.Skip(\"golang.org/issue/73977\")\n")))))))))
1007 (native-inputs
1008 ;; Go 1.26 and later requires Go 1.24.6+ as the bootstrap toolchain.
1009 (alist-replace "go" (list go-1.24) (package-native-inputs go-1.25)))
1010 (properties
1011 (alist-delete 'hidden? (package-properties go-1.24)))))
1012
1013(define-public go-1.27
1014 (package
1015 (inherit go-1.26)
1016 (name "go")
1017 (version "1.27.1")
1018 (source
1019 (origin
1020 (method git-fetch)
1021 (uri (git-reference
1022 (url "https://github.com/golang/go")
1023 (commit (string-append "go" version))))
1024 (file-name (git-file-name name version))
1025 (sha256
1026 (base32 "0cfkl0lzas6fd2y6mg72n0ms8f6aswv5y5qca6nbxnv5d025nrpd"))))))
1027
1028;; This is a placeholder for the next RC version when it's tagged.
1029(define-public go-next
1030 (deprecated-package "go-next" go-1.27))
1031;;
1032;; Default Golang version used in guix/build-system/go.scm to build packages.
1033;;
1034(define-public go go-1.25)
1035
1036(define make-go-std
1037 (mlambdaq (go)
1038 "Return a package which builds the standard library for Go compiler GO."
1039 (package
1040 (name (string-append (package-name go) "-std"))
1041 (version (package-version go))
1042 (source #f)
1043 (build-system go-build-system)
1044 (arguments
1045 `(#:import-path "std"
1046 #:build-flags `("-pkgdir" "pkg") ; "Install" to build directory.
1047 #:allow-go-reference? #t
1048 #:substitutable? #f ; Faster to build than download.
1049 #:tests? #f ; Already tested in the main Go build.
1050 #:go ,go
1051 #:phases
1052 (modify-phases %standard-phases
1053 (delete 'unpack)
1054 (replace 'install
1055 (lambda* (#:key outputs #:allow-other-keys)
1056 (let* ((out (assoc-ref outputs "out"))
1057 (out-cache (string-append out "/var/cache/go/build")))
1058 (copy-recursively (getenv "GOCACHE") out-cache)
1059 (delete-file (string-append out-cache "/trim.txt"))
1060 (delete-file (string-append out-cache "/README")))))
1061 (delete 'install-license-files))))
1062 (home-page (package-home-page go))
1063 (synopsis "Cached standard library build for Go")
1064 (description (package-description go))
1065 (license (package-license go)))))
1066
1067(export make-go-std)
1068
1069;; Make those public so they have a corresponding Cuirass job.
1070(define-public go-std-1.17 (make-go-std go-1.17))
1071(define-public go-std-1.20 (make-go-std go-1.20))
1072(define-public go-std-1.22 (make-go-std go-1.22))
1073(define-public go-std-1.24 (make-go-std go-1.24))
1074(define-public go-std-1.25 (make-go-std go-1.25))
1075(define-public go-std-1.26 (make-go-std go-1.26))
1076(define-public go-std-1.27 (make-go-std go-1.27))
1077
1078;;;
1079;;; Avoid adding new packages to the end of this file. To reduce the chances
1080;;; of a merge conflict, place them above by existing packages with similar
1081;;; functionality or similar names.
1082;;;