* guix/import/go.scm (go-module->guix-package*): Handle errors, remove
(go-module-recursive-import): Remove 'guard', add memoize.
* guix/scripts/import/go.scm (guix-import-go): Adjust.
guix/import/go.scm | 52 +++++++++++++++++++++++---------------
guix/scripts/import/go.scm | 6 ++---
3 files changed, 36 insertions(+), 24 deletions(-)
Toggle diff (115 lines)
diff --git a/guix/import/go.scm b/guix/import/go.scm
index a2863c79ad..5bec31201d 100644
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
-;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; This file is part of GNU Guix.
#:export (go-module->guix-package
+ go-module->guix-package*
go-module-recursive-import))
@@ -631,7 +633,28 @@ hint: use one of the following available versions ~a\n"
-(define go-module->guix-package* (memoize go-module->guix-package))
+(define go-module->guix-package*
+ ;; Disable output buffering so that the following warning gets printed
+ (setvbuf (current-error-port) 'none)
+ (let ((package-name (match args ((name _ ...) name))))
+ (guard (c ((http-get-error? c)
+ (warning (G_ "Failed to import package ~s.
+reason: ~s could not be fetched: HTTP error ~a (~s).
+This package and its dependencies won't be imported.~%")
+ (uri->string (http-get-error-uri c))
+ (http-get-error-code c)
+ (http-get-error-reason c))
+ (warning (G_ "Failed to import package ~s.
+ (apply go-module->guix-package args)))))
(define* (go-module-recursive-import package-name
#:key (goproxy "https://proxy.golang.org")
@@ -641,23 +664,12 @@ hint: use one of the following available versions ~a\n"
- (lambda* (name #:key version repo)
- ;; Disable output buffering so that the following warning gets printed
- (setvbuf (current-error-port) 'none)
- (guard (c ((http-get-error? c)
- (warning (G_ "Failed to import package ~s.
-reason: ~s could not be fetched: HTTP error ~a (~s).
-This package and its dependencies won't be imported.~%")
- (uri->string (http-get-error-uri c))
- (http-get-error-code c)
- (http-get-error-reason c))
- (receive (package-sexp dependencies)
- (go-module->guix-package* name #:goproxy goproxy
- #:pin-versions? pin-versions?)
- (values package-sexp dependencies))))
+ (lambda* (name #:key version repo)
+ (receive (package-sexp dependencies)
+ (go-module->guix-package* name #:goproxy goproxy
+ #:pin-versions? pin-versions?)
+ (values package-sexp dependencies))))
#:guix-name go-module->guix-package-name
diff --git a/guix/scripts/import/go.scm b/guix/scripts/import/go.scm
index 74e8e60cce..071ecdb2ef 100644
--- a/guix/scripts/import/go.scm
+++ b/guix/scripts/import/go.scm
@@ -115,10 +115,10 @@ that are not yet in Guix"))
(map package->definition*
(apply go-module-recursive-import arguments))
- (let ((sexp (apply go-module->guix-package arguments)))
+ (let ((sexp (apply go-module->guix-package* arguments)))
- (leave (G_ "failed to download meta-data for module '~a'~%")
+ (leave (G_ "failed to download meta-data for module '~a'.~%")
(package->definition* sexp))))))
(leave (G_ "too few arguments~%")))
diff --git a/tests/go.scm b/tests/go.scm
index b088ab50d2..929a8b39d1 100644
@@ -286,6 +286,6 @@ package.")
(nix-base32-string->bytevector
"0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5")
- (go-module->guix-package "github.com/go-check/check")))))))
+ (go-module->guix-package* "github.com/go-check/check")))))))