summaryrefslogtreecommitdiff
path: root/gnu/packages/golang.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/golang.scm')
-rw-r--r--gnu/packages/golang.scm266
1 files changed, 261 insertions, 5 deletions
diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index a69e38249f..e9cf75bd7d 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -458,7 +458,7 @@ in the style of communicating sequential processes (@dfn{CSP}).")
(package
(inherit go-1.14)
(name "go")
- (version "1.16.7")
+ (version "1.16.8")
(source
(origin
(method git-fetch)
@@ -468,7 +468,7 @@ in the style of communicating sequential processes (@dfn{CSP}).")
(file-name (git-file-name name version))
(sha256
(base32
- "1id6nsavf7gm78bmzsvym135pi2xa0v75ny51xrw93j70clz9w0h"))))
+ "00zv65v09kr2cljxxqypk980r4b4aqjijhbw4ikppn8km68h831n"))))
(arguments
(substitute-keyword-arguments (package-arguments go-1.14)
((#:tests? _) #t)
@@ -613,6 +613,188 @@ in the style of communicating sequential processes (@dfn{CSP}).")
(alist-replace "go" (list gccgo-10) (package-native-inputs go-1.14))
(package-native-inputs go-1.14))))))
+(define-public go-1.17
+ (package
+ (inherit go-1.16)
+ (name "go")
+ (version "1.17.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/golang/go")
+ (commit (string-append "go" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0wk99lwpzp4qwrksl932lm9vb70nyf4vgb5lxwh7gzjcbhlqj992"))))
+ (outputs '("out" "tests")) ; 'tests' contains distribution tests.
+ (arguments
+ `(#:modules ((ice-9 match)
+ (guix build gnu-build-system)
+ (guix build utils))
+ #:phases
+ (modify-phases %standard-phases
+ (replace 'configure
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((output (assoc-ref outputs "out"))
+ (loader (string-append (assoc-ref inputs "libc")
+ ,(glibc-dynamic-linker))))
+ (setenv "GOOS" "linux")
+ (setenv "GO_LDSO" loader)
+ (setenv "GOROOT" (getcwd))
+ (setenv "GOROOT_FINAL" (string-append output "/lib/go"))
+ (setenv "GOGC" "400")
+ (setenv "GOCACHE" "/tmp/go-cache"))))
+ (add-after 'unpack 'patch-source
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((net-base (assoc-ref inputs "net-base"))
+ (tzdata-path (string-append (assoc-ref inputs "tzdata")
+ "/share/zoneinfo")))
+ ;; XXX: Remove when #49729 is merged?
+ (for-each make-file-writable (find-files "src"))
+
+ ;; Having the patch in the 'patches' field of <origin> breaks
+ ;; the 'TestServeContent' test due to the fact that
+ ;; timestamps are reset. Thus, apply it from here.
+ (invoke "patch" "-p1" "--force" "-i"
+ (assoc-ref inputs "go-skip-gc-test.patch"))
+ (invoke "patch" "-p1" "--force" "-i"
+ (assoc-ref inputs "go-fix-script-tests.patch"))
+
+ (substitute* "src/os/os_test.go"
+ (("/usr/bin") (getcwd))
+ (("/bin/sh") (which "sh")))
+
+ (substitute* "src/cmd/go/testdata/script/cgo_path_space.txt"
+ (("/bin/sh") (which "sh")))
+
+ ;; fix shebang for testar script
+ ;; note the target script is generated at build time.
+ (substitute* "misc/cgo/testcarchive/carchive_test.go"
+ (("/usr/bin/env bash") (which "bash")))
+
+ (substitute* "src/net/lookup_unix.go"
+ (("/etc/protocols")
+ (string-append net-base "/etc/protocols")))
+ (substitute* "src/net/port_unix.go"
+ (("/etc/services")
+ (string-append net-base "/etc/services")))
+ (substitute* "src/time/zoneinfo_unix.go"
+ (("/usr/share/zoneinfo/") tzdata-path)))))
+ (add-after 'patch-source 'disable-failing-tests
+ (lambda _
+ ;; Disable failing tests: these tests attempt to access
+ ;; commands or network resources which are neither available
+ ;; nor necessary for the build to succeed.
+ (for-each
+ (match-lambda
+ ((file test)
+ (let ((regex (string-append "^(func\\s+)(" test "\\()")))
+ (substitute* file
+ ((regex all before test_name)
+ (string-append before "Disabled" test_name))))))
+ '(("src/net/cgo_unix_test.go" "TestCgoLookupPort")
+ ("src/net/cgo_unix_test.go" "TestCgoLookupPortWithCancel")
+ ;; 127.0.0.1 doesn't exist
+ ("src/net/cgo_unix_test.go" "TestCgoLookupPTR")
+ ("src/net/cgo_unix_test.go" "TestCgoLookupPTRWithCancel")
+ ;; /etc/services doesn't exist
+ ("src/net/parse_test.go" "TestReadLine")
+ ;; The user's directory doesn't exist
+ ("src/os/os_test.go" "TestUserHomeDir")))
+
+ ;; These tests fail on aarch64-linux
+ (substitute* "src/cmd/dist/test.go"
+ (("t.registerHostTest\\(\"testsanitizers/msan.*") ""))))
+ (add-after 'patch-source 'enable-external-linking
+ (lambda _
+ ;; Invoke GCC to link any archives created with GCC (that is, any
+ ;; packages built using 'cgo'), because Go doesn't know how to
+ ;; handle the runpaths but GCC does. Use substitute* rather than
+ ;; a patch since these files are liable to change often.
+ ;;
+ ;; XXX: Replace with GO_EXTLINK_ENABLED=1 or similar when
+ ;; <https://github.com/golang/go/issues/31544> and/or
+ ;; <https://github.com/golang/go/issues/43525> are resolved.
+ (substitute* "src/cmd/link/internal/ld/config.go"
+ (("iscgo && externalobj") "iscgo"))
+ (substitute* '("src/cmd/nm/nm_cgo_test.go"
+ "src/cmd/dist/test.go")
+ (("^func.*?nternalLink\\(\\).*" all)
+ (string-append all "\n\treturn false\n")))))
+ (replace 'build
+ (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
+ (let* ((njobs (if parallel-build? (parallel-job-count) 1)))
+ (with-directory-excursion "src"
+ (setenv "GOMAXPROCS" (number->string njobs))
+ (invoke "sh" "make.bash" "--no-banner")))))
+ (replace 'check
+ (lambda* (#:key target (tests? (not target)) (parallel-tests? #t)
+ #:allow-other-keys)
+ (let* ((njobs (if parallel-tests? (parallel-job-count) 1)))
+ (when tests?
+ (with-directory-excursion "src"
+ (setenv "GOMAXPROCS" (number->string njobs))
+ (invoke "sh" "run.bash" "--no-rebuild"))))))
+ (add-before 'install 'unpatch-perl-shebangs
+ (lambda _
+ ;; Avoid inclusion of perl in closure by rewriting references
+ ;; to perl input in sourcecode generators and test scripts
+ (substitute* (cons "src/net/http/cgi/testdata/test.cgi"
+ (find-files "src" "\\.pl$"))
+ (("^#!.*") "#!/usr/bin/env perl\n"))))
+ (replace 'install
+ (lambda* (#:key outputs #:allow-other-keys)
+ ;; Notably, we do not install archives (180M), which Go will
+ ;; happily recompile quickly (and cache) if needed, almost
+ ;; surely faster than they could be substituted.
+ ;;
+ ;; The main motivation for pre-compiled archives is to use
+ ;; libc-linked `net' or `os' packages without a C compiler,
+ ;; but on Guix a C compiler is necessary to properly link the
+ ;; final binaries anyway. Many build flags also invalidate
+ ;; these pre-compiled archives, so in practice Go often
+ ;; recompiles them anyway.
+ ;;
+ ;; Upstream is also planning to no longer install these
+ ;; archives: <https://github.com/golang/go/issues/47257>
+ ;;
+ ;; When necessary, a custom pre-compiled library package can
+ ;; be created with `#:import-path "std"' and used with
+ ;; `-pkgdir'.
+ (let* ((out (assoc-ref outputs "out"))
+ (tests (assoc-ref outputs "tests")))
+ (for-each
+ (lambda (file)
+ (copy-recursively file (string-append out "/lib/go/" file)))
+ '("lib" "VERSION" "pkg/include" "pkg/tool"))
+
+ (for-each
+ (match-lambda
+ ((file dest output)
+ ;; Copy to output/dest and symlink from output/lib/go/file.
+ (let ((file* (string-append output "/lib/go/" file))
+ (dest* (string-append output "/" dest)))
+ (copy-recursively file dest*)
+ (mkdir-p (dirname file*))
+ (symlink (string-append "../../" dest) file*))))
+ `(("bin" "bin" ,out)
+ ("src" "share/go/src" ,out)
+ ("misc" "share/go/misc" ,out)
+ ("doc" "share/doc/go/doc" ,out)
+ ("api" "share/go/api" ,tests)
+ ("test" "share/go/test" ,tests))))))
+ (add-after 'install 'install-doc-files
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (for-each
+ (lambda (file)
+ (install-file file (string-append out "/share/doc/go")))
+ '("AUTHORS" "CONTRIBUTORS" "CONTRIBUTING.md" "PATENTS"
+ "README.md" "SECURITY.md"))))))))
+ (inputs (alist-delete "gcc:lib" (package-inputs go-1.16)))))
+
(define-public go go-1.14)
(define-public go-0xacab-org-leap-shapeshifter
@@ -1381,6 +1563,12 @@ Go.")
(url "https://github.com/sevlyar/go-daemon")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
+ (modules '((guix build utils)))
+ (snippet
+ ;; XXX: Remove when updating
+ '(begin
+ (substitute* "compilation_test.go"
+ ((".*\"darwin/386\".*") ""))))
(sha256
(base32 "1y3gnxaifykcjcbzx91lz9bc93b95w3xj4rjxjbii26pm3j7gqyk"))))
(build-system go-build-system)
@@ -1420,7 +1608,9 @@ Go.")
(("/bin/sleep" command)
(string-append
(assoc-ref (or native-inputs inputs) "coreutils")
- command))))))))
+ command)))
+ (substitute* "src/github.com/keybase/go-ps/process_openbsd.go"
+ (("^// \\+build ignore") "")))))))
(native-inputs
`(("coreutils" ,coreutils)
("go-github-com-stretchr-testify"
@@ -2759,6 +2949,68 @@ developers to use @code{http} methods explicitly and in a way that's consistent
with the HTTP protocol definition.")
(license license:expat)))
+(define-public go-cloud-google-com-go-compute-metadata
+ (package
+ (name "go-cloud-google-com-go-compute-metadata")
+ (version "0.81.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/googleapis/google-cloud-go")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "15jgynqb5pbxqbj3a7ii970yn4srsw1dbxzxnhpkfkmplalpgyh3"))))
+ (build-system go-build-system)
+ (arguments
+ '(#:unpack-path "cloud.google.com/go"
+ #:import-path "cloud.google.com/go/compute/metadata"))
+ (home-page
+ "https://pkg.go.dev/cloud.google.com/go/compute/metadata")
+ (synopsis
+ "Go wrapper for Google Compute Engine metadata service")
+ (description
+ "This package provides access to Google Compute Engine (GCE) metadata and
+API service accounts for Go.")
+ (license license:asl2.0)))
+
+(define-public go-github-com-google-gmail-oauth2-tools-go-sendgmail
+ (let ((commit "e3229155a4037267ce40f1a3a681f53221aa4d8d")
+ (revision "0"))
+ (package
+ (name "go-github-com-google-gmail-oauth2-tools-go-sendgmail")
+ (version (git-version "0.0.0" revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/google/gmail-oauth2-tools")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1cxpkiaajhq1gjsg47r2b5xgck0r63pvkyrkm7af8c8dw7fyn64f"))))
+ (propagated-inputs
+ `(("go-golang-org-x-oauth2" ,go-golang-org-x-oauth2)
+ ("go-cloud-google-com-go-compute-metadata"
+ ,go-cloud-google-com-go-compute-metadata)))
+ (build-system go-build-system)
+ (arguments
+ '(#:unpack-path "github.com/google/gmail-oauth2-tools"
+ #:import-path "github.com/google/gmail-oauth2-tools/go/sendgmail"))
+ (home-page
+ "https://github.com/google/gmail-oauth2-tools/tree/master/go/sendgmail")
+ (synopsis
+ "Sendmail-compatible tool for using Gmail with @code{git send-email}")
+ (description
+ "The @command{sendgmail} command provides a minimal sendmail-compatible
+front-end that connects to Gmail using OAuth2. It is specifically designed
+for use with @code{git send-email}. The command needs a Gmail API key to
+function.")
+ (license license:asl2.0))))
+
(define-public go-github-com-google-cadvisor
(let ((commit "2ed7198f77395ee9a172878a0a7ab92ab59a2cfd")
(revision "0"))
@@ -4791,7 +5043,8 @@ as conversion to and from @command{net.Addr}.")
(file-name (git-file-name name version))
(sha256
(base32
- "10mcnvi5qmn00vpyk6si8gjka7p654wr9hac4zc9w5h3ickhvbdc"))))
+ "10mcnvi5qmn00vpyk6si8gjka7p654wr9hac4zc9w5h3ickhvbdc"))
+ (patches (search-patches "go-github-com-urfave-cli-fix-tests.patch"))))
(build-system go-build-system)
(arguments
'(#:import-path "github.com/urfave/cli"))
@@ -4817,7 +5070,10 @@ fast and distributable command line applications in an expressive way.")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
- (base32 "08pvn7gyfznni72xrxfh2x6xxa8ykr7l1ka278js8g8qkh71bj8l"))))
+ (base32 "08pvn7gyfznni72xrxfh2x6xxa8ykr7l1ka278js8g8qkh71bj8l"))
+ ;; XXX: Remove patch when updating.
+ (patches
+ (search-patches "go-github-com-urfave-cli-v2-fix-tests.patch"))))
(arguments
'(#:import-path "github.com/urfave/cli/v2"))))