Subject: [bug#44178] [PATCH] Create importer for Go modules

From: Timmy Douglas <[email-masked]>
Date: Wed, 27 Jan 2021 21:01:03 -0800

I checked out https://github.com/kat-co/guix/tree/create-go-importer:

$ ./pre-inst-env guix import go -r github.com/coredns/coredns
;;; note: source file /s/timmy/guix/guix/import/go.scm
;;;       newer than compiled /home/timmy/.cache/guile/ccache/3.0-LE-8-4.3/s/timmy/guix/guix/import/go.scm.go

Starting download of /tmp/guix-file.jkncVo
>From https://proxy.golang.org/github.com/coredns/coredns/@v/v1.8.1.mod...
 v1.8.1.mod  2KiB                     870KiB/s 00:00 [##################] 100.0%

Starting download of /tmp/guix-file.GtI9fs
>From https://proxy.golang.org/k8s.io/klog/@v/v1.0.0.mod...
 v1.0.0.mod  68B                      189KiB/s 00:00 [##################] 100.0%
Backtrace:
In ice-9/boot-9.scm:
  1736:10 13 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
          12 (apply-smob/0 #<thunk 7fdc57f964e0>)
In ice-9/boot-9.scm:
    718:2 11 (call-with-prompt _ _ #<procedure default-prompt-handle?>)
In ice-9/eval.scm:
    619:8 10 (_ #(#(#<directory (guile-user) 7fdc57be3f00>)))
In guix/ui.scm:
  2154:12  9 (run-guix-command _ . _)
In guix/scripts/import.scm:
   120:11  8 (guix-import . _)
In ice-9/eval.scm:
    159:9  7 (_ _)
In guix/import/utils.scm:
   464:27  6 (recursive-import _ #:repo->guix-package _ #:guix-name _ ?)
In srfi/srfi-1.scm:
   586:17  5 (map1 (("k8s.io/klog" #f) ("k8s.io/client-go" #f) (?) ?))
In guix/import/utils.scm:
   453:33  4 (lookup-node "k8s.io/klog" #f)
In guix/utils.scm:
    700:8  3 (call-with-temporary-output-file #<procedure 7fdc464b03?>)
In ice-9/eval.scm:
   293:34  2 (_ #(#(#(#(#(#(#(#(#<directory ?> ?) ?) ?) ?) ?) ?) ?) ?))
    155:9  1 (_ #(#(#<directory (guix import go) 7fdc55b65f00>) #f))
In unknown file:
           0 (list-ref #f 1)

ERROR: In procedure list-ref:
In procedure list-ref: Wrong type argument in position 1: #f

This is due to:

(go-module->guix-package "k8s.io/klog")

The temp file looks like this:

module k8s.io/klog

go 1.12

require github.com/go-logr/logr v0.1.0

-> (fetch-module-meta-data '("github.com/go-logr/logr"))
-> (string->uri (format #f "https://~a?go-get=1" module-path)) -> #f
-> (http-fetch #f)

Is there a better way to debug this? `guix import` kicked me back to the
cmd line instead of the guile debugger, which is understandable for
users, but the stacktrace is missing a lot of information. I opened
emacs and geiser and had to eval a bunch of things to narrow it down. It
feels like I'm doing it wrong. (I don't have much experience with scheme)