GNU bug report logs - #44178
Add a Go Module Importer

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Katherine Cox-Buday <cox.katherine.e@HIDDEN>; dated Fri, 23 Oct 2020 14:08:01 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 44178 <at> debbugs.gnu.org:


Received: (at 44178) by debbugs.gnu.org; 11 Nov 2020 20:48:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 11 15:48:26 2020
Received: from localhost ([127.0.0.1]:42958 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kcx2U-0000WW-UY
	for submit <at> debbugs.gnu.org; Wed, 11 Nov 2020 15:48:26 -0500
Received: from mail-il1-f169.google.com ([209.85.166.169]:46754)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <cox.katherine.e@HIDDEN>) id 1kcx2Q-0000WF-Jt
 for 44178 <at> debbugs.gnu.org; Wed, 11 Nov 2020 15:48:22 -0500
Received: by mail-il1-f169.google.com with SMTP id a20so3188783ilk.13
 for <44178 <at> debbugs.gnu.org>; Wed, 11 Nov 2020 12:48:18 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=+MxwqtKzYmC/HnM93tPv6rhG6PUxVf3KaxMdg82XBAs=;
 b=E8rJmYziBt3hK9T5sxcVwxIXXAmud5yEi55UKBlVCeuXKsFbMBiJTm7DmVNnqsgSbl
 roGAMAG9E/S7HucJBiAsmNYQzHmf3a2R+K42TzVIJ3fu4pQEUj1UHRiiJZnxDHjruKY4
 sb0AYpMIOQzEobPOa97y7HyYVFI5gAVPLW0PmULJbGpldWsojxfC/xGgTalFt6B73Pzi
 Fysex3xkxTgoTsPJHXSct6XIrLFAzF09HcsIfxXJSZRE665KKXEzIk2fzkWePd+jrpdk
 Fq2fvFnz4fuOYnL8fo+96px7u6CWJbJEIQEWLGbNfnbqQ5qZVZ0/8O0k2si0bjmbUkjJ
 7vng==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version;
 bh=+MxwqtKzYmC/HnM93tPv6rhG6PUxVf3KaxMdg82XBAs=;
 b=oDRZU7WBOhAzLxCyX1aojUZXRiIQByTiK80WDKWiGEn9xD6kinfKe4AkHA3GKidEhd
 iUJhrYTqKiFiqr+GFjbONmsL20IDlxJk6Urp73xp9l5ldaiBsVPvxfRyOvbQx/wxvgLX
 FjGouNAsLdjD2CamRRU7f6qpHLkT03sImn75NvOcezzK8LK7i9qrUXZcgCZCadrTFGMG
 Vlmaxv8ggZIVnEzK7YNqljqTFPKLZtl3u9LHTKl4dt4A3B3tj7bDLLfyc7Uxtl94+sum
 PIQgL4yyKkVN5Do2fiIC6/f/QTmIQLJxFcdY+mvtUdnvIGXNe1uUFWrQ5dcwBQiMlAdX
 y5uw==
X-Gm-Message-State: AOAM5311aVPKRRsVZsTZQuoNiq5/cUgIK8EN5eTr6gHlR2hPjDKCSgeg
 OQTAGt+/9PC0e2MiW8k3XbY=
X-Google-Smtp-Source: ABdhPJyo+zFYmTwxwTzKFvclNSiDlotuDzDWuJIE8LKe6EAxRMvyLmdEw7HRQGDThy6FwYLG9/fZwg==
X-Received: by 2002:a05:6e02:2cc:: with SMTP id
 v12mr20786794ilr.115.1605127692911; 
 Wed, 11 Nov 2020 12:48:12 -0800 (PST)
Received: from washu-v4 (172-221-246-205.res.spectrum.com. [172.221.246.205])
 by smtp.gmail.com with ESMTPSA id
 y9sm1725065ily.85.2020.11.11.12.48.11
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 11 Nov 2020 12:48:11 -0800 (PST)
From: Katherine Cox-Buday <cox.katherine.e@HIDDEN>
To: Marius Bakke <marius@HIDDEN>
Subject: Re: [bug#44178] Add a Go Module Importer
References: <87sga5kpdp.fsf@HIDDEN> <87blg5dkla.fsf@HIDDEN>
Date: Wed, 11 Nov 2020 14:48:10 -0600
In-Reply-To: <87blg5dkla.fsf@HIDDEN> (Marius Bakke's message of "Tue, 10 Nov
 2020 21:26:41 +0100")
Message-ID: <87v9ebpqlx.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 44178
Cc: 44178 <at> debbugs.gnu.org, Helio Machado <0x2b3bfa0@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Marius Bakke <marius@HIDDEN> writes:

> I just want to say thanks a lot for this!  I tested it, and it pretty
> much works as advertised.

You're very welcome!

I have more changes locally which fix some edge-cases. I'm using
`go-ethereum` as my test case since someone mentioned that. Plus I need
to make some of the changes Ludovic pointed out. Still, we're underway!

-- 
Katherine




Information forwarded to guix-patches@HIDDEN:
bug#44178; Package guix-patches. Full text available.

Message received at 44178 <at> debbugs.gnu.org:


Received: (at 44178) by debbugs.gnu.org; 11 Nov 2020 01:23:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 10 20:23:44 2020
Received: from localhost ([127.0.0.1]:39569 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kcerQ-0006Dc-DP
	for submit <at> debbugs.gnu.org; Tue, 10 Nov 2020 20:23:44 -0500
Received: from mail-qt1-f173.google.com ([209.85.160.173]:33788)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <0x2b3bfa0@HIDDEN>) id 1kcerO-0006DP-1T
 for 44178 <at> debbugs.gnu.org; Tue, 10 Nov 2020 20:23:42 -0500
Received: by mail-qt1-f173.google.com with SMTP id i12so300949qtj.0
 for <44178 <at> debbugs.gnu.org>; Tue, 10 Nov 2020 17:23:42 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
 bh=y8nrYLjKxck1A5J3/CkEvWoKDcNwo+P2S2p8LTJikj0=;
 b=pJ92/7zMYpww19dNeo18coiYTUrcwoiwRN4F/lnifFVRL+J08XedjNKy3rV3ekS6GQ
 IHKZlZY6l4GgB0TwHVVwee72JboJTmiZRhs3Hdygr0gFPKPNa34VwLurJuUO7IRrUmcy
 LCLtsDAZqdCR8Oy7BBK4Up3ryYfE24oMsbhLELMtp5ZI7YMvwLqVlcAM1B+f/B1/L2ow
 qoidMmUzhBbCkTK6zkXRNUnTWK6cmXuX5pScDHffRzisu+C6eMVNzeJNV6Z8uOK1T1LA
 j0xBNhBSW1dbqu3S4lynuci1PhyPu28WyRMNcUySVMfovd5FIHAoy3iinzAdYJqQnfZS
 cshg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to;
 bh=y8nrYLjKxck1A5J3/CkEvWoKDcNwo+P2S2p8LTJikj0=;
 b=meFK0MF+eoC+DOnwoZ5xrQxpV1c6HTzZF44zpNduMk36PQAuiMvr6zM0ezVutEL4nT
 lVneCVs+j4OyVSHa4rSrpcnq6XPOhoaQlHdpG4KUikaZOP03H7gGaJ2cW/TM7pL8zrup
 2KxJe0SbDSP0Zq+7lvIZmJw2BmLoVA+TukxJhHAJYK6vcWk6nLGFozIGXaL3q/eoTGbx
 wzQym2Cj4/g1KL/R3angSoPbspUGseOqC8DYRh8eKKlephLjnTcY+LmL/viK8pUEZkvh
 gW0CPD+kOvFsSpQgi+tsUnyAOTiFoOW0yzZ0b6yWJpNXtlLDY6Rsrc1fqhYKR9X2mKOs
 jCgQ==
X-Gm-Message-State: AOAM532NlKbhFlzPtE8JKDAgLr3fcZZaSkvd3IRLog8dASOnBgXg6Un0
 QHUBHFZeHybsj2AhkWsATIM9TrUFSB6tUwF2LKy5urTWU2m0Fg==
X-Google-Smtp-Source: ABdhPJwUFF5LFW9/3Jc0IaAkwlIhgRoO1lw96fGyv9DWUA2xlV8DdmcubDXszWCkJL6MTmRRSQeku3gX/3yRG9v2OiI=
X-Received: by 2002:aed:38ca:: with SMTP id k68mr9742206qte.28.1605057816323; 
 Tue, 10 Nov 2020 17:23:36 -0800 (PST)
MIME-Version: 1.0
References: <87sga5kpdp.fsf@HIDDEN> <87blg5dkla.fsf@HIDDEN>
 <CANe01w55ZO=_9v0HcDv248UsoLUXb_9WVAgM4LqiZ4E-r1XgXg@HIDDEN>
In-Reply-To: <CANe01w55ZO=_9v0HcDv248UsoLUXb_9WVAgM4LqiZ4E-r1XgXg@HIDDEN>
From: Helio Machado <0x2b3bfa0@HIDDEN>
Date: Wed, 11 Nov 2020 02:23:00 +0100
Message-ID: <CANe01w5DxwrF+APLbcNMaUhs4h05EXC1HdRJ_YT8CRy6ULxUYw@HIDDEN>
Subject: Re: [bug#44178] Add a Go Module Importer
To: 44178 <at> debbugs.gnu.org
Content-Type: multipart/alternative; boundary="000000000000fc6c5a05b3caa49f"
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 44178
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--000000000000fc6c5a05b3caa49f
Content-Type: text/plain; charset="UTF-8"

Thanks for the ping, Marius! I've been quite busy with some yak shaving
tasks, but my importer is already working and has some interesting
improvements, like elegant module fetching from the official module proxy,
license extraction and recursive import support.

I need to fix an esoteric bug that trips the kernel's out-of-memory killer
when building a derivation with dependencies, but the importer part works
pretty well.

You can take a look to [my changes][1] for some readily backportable ideas,
like [the compact algorithm for uppercase path escaping][2].

Please forgive the code quality and the possible backwards-compatibility
mistakes; this is an unfinished proof of concept.

$ guix import go-modules -r github.com/FiloSottile/age # Please refer to
the issue 43872 for more information about the resting environment

[1]:
https://github.com/0x2b3bfa0/guix-go-modules/commit/5defe897065c5d3e63740932b360474132c77877
[2]:
https://github.com/0x2b3bfa0/guix-go-modules/blob/main/guix/build-system/go.scm#L65-L71

On Wed, 11 Nov 2020 at 02:19, Helio Machado <0x2b3bfa0@HIDDEN> wrote:

> Thanks for the ping, Marius! I've been quite busy with some yak shaving
> tasks, but my importer is already working and has some interesting
> improvements, like elegant module fetching from the official module proxy,
> license extraction and recursive import support.
>
> I need to fix an esoteric bug that trips the kernel's out-of-memory killer
> when building a derivation with dependencies, but the importer part works
> pretty well.
>
> You can take a look to [my changes][1] for some readily backportable
> ideas, like [the compact algorithm for uppercase path escaping][2].
>
> Please forgive the code quality and the possible backwards-compatibility
> mistakes; this is an unfinished proof of concept.
>
> [1]:
> https://github.com/0x2b3bfa0/guix-go-modules/commit/5defe897065c5d3e63740932b360474132c77877
> [2]:
> https://github.com/0x2b3bfa0/guix-go-modules/blob/main/guix/build-system/go.scm#L65-L71
>
> On Tue, 10 Nov 2020 at 21:26, Marius Bakke <marius@HIDDEN> wrote:
>
>> Katherine Cox-Buday <cox.katherine.e@HIDDEN> writes:
>>
>> >>From cc92cbcf5ae89891f478f319e955419800bdfcf9 Mon Sep 17 00:00:00 2001
>> > From: Katherine Cox-Buday <cox.katherine.e@HIDDEN>
>> > Date: Thu, 22 Oct 2020 19:40:17 -0500
>> > Subject: [PATCH] * guix/import/go.scm: Created Go Importer *
>> >  guix/scripts/import.scm: Created Go Importer Subcommand *
>> guix/import/go.scm
>> >  (importers): Added Go Importer Subcommand
>>
>> I just want to say thanks a lot for this!  I tested it, and it pretty
>> much works as advertised.
>>
>> Cc'ing Helio who was working on a Go importer as well recently.
>>
>

--000000000000fc6c5a05b3caa49f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div di=
r=3D"ltr"><div dir=3D"ltr">Thanks for the ping, Marius! I&#39;ve been quite=
 busy with some yak shaving tasks, but my importer is already working and h=
as some interesting improvements, like elegant module fetching from the off=
icial module proxy, license extraction and recursive=C2=A0import support.</=
div><div dir=3D"ltr"><br><div>I need to fix an esoteric bug that trips the =
kernel&#39;s out-of-memory killer when building a derivation with dependenc=
ies, but the importer part works pretty well.</div><div><br></div><div>You =
can take a look to [my changes][1] for some readily backportable ideas, lik=
e [the compact algorithm for uppercase path escaping][2].</div><div><br></d=
iv><div>Please forgive the code quality and the possible backwards-compatib=
ility mistakes; this is an unfinished proof of concept.</div><div><br></div=
><div>$ guix import go-modules -r <a href=3D"http://github.com/FiloSottile/=
age" target=3D"_blank">github.com/FiloSottile/age</a> # Please refer to the=
 issue 43872 for more information about the resting environment</div><div><=
br></div><div>[1]:=C2=A0<a href=3D"https://github.com/0x2b3bfa0/guix-go-mod=
ules/commit/5defe897065c5d3e63740932b360474132c77877" target=3D"_blank">htt=
ps://github.com/0x2b3bfa0/guix-go-modules/commit/5defe897065c5d3e63740932b3=
60474132c77877</a></div><div>[2]:=C2=A0<a href=3D"https://github.com/0x2b3b=
fa0/guix-go-modules/blob/main/guix/build-system/go.scm#L65-L71" target=3D"_=
blank">https://github.com/0x2b3bfa0/guix-go-modules/blob/main/guix/build-sy=
stem/go.scm#L65-L71</a></div></div></div></div></div></div></div><br><div c=
lass=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, 11 Nov 2=
020 at 02:19, Helio Machado &lt;<a href=3D"mailto:0x2b3bfa0@HIDDEN" targ=
et=3D"_blank">0x2b3bfa0@HIDDEN</a>&gt; wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;bo=
rder-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">=
<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">Thanks =
for the ping, Marius! I&#39;ve been quite busy with some yak shaving tasks,=
 but my importer is already working and has some interesting improvements, =
like elegant module fetching from the official module proxy, license extrac=
tion and recursive=C2=A0import support.</div><div dir=3D"ltr"><br><div>I ne=
ed to fix an esoteric bug that trips the kernel&#39;s out-of-memory killer =
when building a derivation with dependencies, but the importer part works p=
retty well.</div><div><br></div><div>You can take a look to [my changes][1]=
 for some readily backportable ideas, like [the compact algorithm for upper=
case path escaping][2].</div><div><br></div><div>Please forgive the code qu=
ality and the possible backwards-compatibility mistakes; this is an unfinis=
hed proof of concept.</div><div><br></div><div>[1]: <a href=3D"https://gith=
ub.com/0x2b3bfa0/guix-go-modules/commit/5defe897065c5d3e63740932b360474132c=
77877" target=3D"_blank">https://github.com/0x2b3bfa0/guix-go-modules/commi=
t/5defe897065c5d3e63740932b360474132c77877</a></div><div>[2]:=C2=A0<a href=
=3D"https://github.com/0x2b3bfa0/guix-go-modules/blob/main/guix/build-syste=
m/go.scm#L65-L71" target=3D"_blank">https://github.com/0x2b3bfa0/guix-go-mo=
dules/blob/main/guix/build-system/go.scm#L65-L71</a></div></div></div></div=
></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr"=
>On Tue, 10 Nov 2020 at 21:26, Marius Bakke &lt;<a href=3D"mailto:marius@gn=
u.org" target=3D"_blank">marius@HIDDEN</a>&gt; wrote:<br></div><blockquote=
 class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:=
1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left=
:1ex">Katherine Cox-Buday &lt;<a href=3D"mailto:cox.katherine.e@HIDDEN" =
target=3D"_blank">cox.katherine.e@HIDDEN</a>&gt; writes:<br>
<br>
&gt;&gt;From cc92cbcf5ae89891f478f319e955419800bdfcf9 Mon Sep 17 00:00:00 2=
001<br>
&gt; From: Katherine Cox-Buday &lt;<a href=3D"mailto:cox.katherine.e@gmail.=
com" target=3D"_blank">cox.katherine.e@HIDDEN</a>&gt;<br>
&gt; Date: Thu, 22 Oct 2020 19:40:17 -0500<br>
&gt; Subject: [PATCH] * guix/import/go.scm: Created Go Importer *<br>
&gt;=C2=A0 guix/scripts/import.scm: Created Go Importer Subcommand * guix/i=
mport/go.scm<br>
&gt;=C2=A0 (importers): Added Go Importer Subcommand<br>
<br>
I just want to say thanks a lot for this!=C2=A0 I tested it, and it pretty<=
br>
much works as advertised.<br>
<br>
Cc&#39;ing Helio who was working on a Go importer as well recently.<br>
</blockquote></div>
</blockquote></div>

--000000000000fc6c5a05b3caa49f--




Information forwarded to guix-patches@HIDDEN:
bug#44178; Package guix-patches. Full text available.

Message received at 44178 <at> debbugs.gnu.org:


Received: (at 44178) by debbugs.gnu.org; 10 Nov 2020 20:26:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 10 15:26:52 2020
Received: from localhost ([127.0.0.1]:39035 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kcaE8-0002wy-1i
	for submit <at> debbugs.gnu.org; Tue, 10 Nov 2020 15:26:52 -0500
Received: from eggs.gnu.org ([209.51.188.92]:37276)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <marius@HIDDEN>) id 1kcaE6-0002wZ-Gi
 for 44178 <at> debbugs.gnu.org; Tue, 10 Nov 2020 15:26:50 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:40212)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <marius@HIDDEN>)
 id 1kcaE1-0007XA-7Q; Tue, 10 Nov 2020 15:26:45 -0500
Received: from host-37-191-236-253.lynet.no ([37.191.236.253]:51050
 helo=localhost)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <marius@HIDDEN>)
 id 1kcaE0-0004zO-02; Tue, 10 Nov 2020 15:26:44 -0500
From: Marius Bakke <marius@HIDDEN>
To: Katherine Cox-Buday <cox.katherine.e@HIDDEN>, 44178 <at> debbugs.gnu.org
Subject: Re: [bug#44178] Add a Go Module Importer
In-Reply-To: <87sga5kpdp.fsf@HIDDEN>
References: <87sga5kpdp.fsf@HIDDEN>
Date: Tue, 10 Nov 2020 21:26:41 +0100
Message-ID: <87blg5dkla.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 44178
Cc: Helio Machado <0x2b3bfa0@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--=-=-=
Content-Type: text/plain

Katherine Cox-Buday <cox.katherine.e@HIDDEN> writes:

>>From cc92cbcf5ae89891f478f319e955419800bdfcf9 Mon Sep 17 00:00:00 2001
> From: Katherine Cox-Buday <cox.katherine.e@HIDDEN>
> Date: Thu, 22 Oct 2020 19:40:17 -0500
> Subject: [PATCH] * guix/import/go.scm: Created Go Importer *
>  guix/scripts/import.scm: Created Go Importer Subcommand * guix/import/go.scm
>  (importers): Added Go Importer Subcommand

I just want to say thanks a lot for this!  I tested it, and it pretty
much works as advertised.

Cc'ing Helio who was working on a Go importer as well recently.

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQFDBAEBCgAtFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAl+q94EPHG1hcml1c0Bn
bnUub3JnAAoJEKKgbfKjOlT6smgH/ibghemWudkskluP5si3VgUb9JO49uiUgDv3
CaKbs/SOvySUPFgl+8ceLWKgLTQeNVGBgcRBA+aiL0hgAYw/JTBndMHEJ1aZMevw
WUDhIMojlbtfw8wBJuVROjPKcXZW5WXZIKQ1GyqpQ/AP72uZcgI7xB0Qbh0ztQq4
uhZcEiDvgCGfsFWOphpuqxoB2rUpEruLaUj4kkEhccArt79WbgVLF3lTijM1Fhff
Mk3r+4MCdmCL3pZsnDcoY/qNl4jGxqP2mj+rszQFqR6da8gIEhkM52NI3U9VoWLp
gaLq4y4jQp4cdMPY4r2WE5jm7KryGcP/4KHFmf4g/8cvD0Lj5dk=
=hW6A
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#44178; Package guix-patches. Full text available.

Message received at 44178 <at> debbugs.gnu.org:


Received: (at 44178) by debbugs.gnu.org; 28 Oct 2020 10:42:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Oct 28 06:42:34 2020
Received: from localhost ([127.0.0.1]:47341 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kXiuX-0003Fs-Ri
	for submit <at> debbugs.gnu.org; Wed, 28 Oct 2020 06:42:34 -0400
Received: from eggs.gnu.org ([209.51.188.92]:38704)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1kXiuV-0003Fg-TU
 for 44178 <at> debbugs.gnu.org; Wed, 28 Oct 2020 06:42:32 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:41114)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1kXiuQ-00040m-Kw; Wed, 28 Oct 2020 06:42:26 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:38492 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1kXiuQ-00054k-3K; Wed, 28 Oct 2020 06:42:26 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Katherine Cox-Buday <cox.katherine.e@HIDDEN>
Subject: Re: [bug#44178] Add a Go Module Importer
In-Reply-To: <87sga5kpdp.fsf@HIDDEN> (Katherine Cox-Buday's message of
 "Fri, 23 Oct 2020 09:06:58 -0500")
References: <87sga5kpdp.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Date: Wed, 28 Oct 2020 11:42:24 +0100
Message-ID: <878sbq4oof.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 44178
Cc: 44178 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi Katherine,

Katherine Cox-Buday <cox.katherine.e@HIDDEN> skribis:

>>From cc92cbcf5ae89891f478f319e955419800bdfcf9 Mon Sep 17 00:00:00 2001
> From: Katherine Cox-Buday <cox.katherine.e@HIDDEN>
> Date: Thu, 22 Oct 2020 19:40:17 -0500
> Subject: [PATCH] * guix/import/go.scm: Created Go Importer *
>  guix/scripts/import.scm: Created Go Importer Subcommand * guix/import/go=
.scm
>  (importers): Added Go Importer Subcommand

Nice!  I think that can make a lot of people happy.  :-)

Here=E2=80=99s a quick review.  I won=E2=80=99t promise I can reply to foll=
owups in the
coming days because with the release preparation going on, I=E2=80=99d rath=
er
focus on that.  So perhaps this patch will have to wait until after this
release, but certainly before the next one!

> +(define (escape-capital-letters s)
> +  "To avoid ambiguity when serving from case-insensitive file systems, t=
he
> +$module and $version elements are case-encoded by replacing every upperc=
ase
> +letter with an exclamation mark followed by the corresponding lower-case
> +letter."
> +  (let ((escaped-string (string)))
> +    (string-for-each-index
> +     (lambda (i)
> +       (let ((c (string-ref s i)))
> +         (set! escaped-string
> +           (string-concatenate
> +            (list escaped-string
> +                  (if (char-upper-case? c) "!" "")
> +                  (string (char-downcase c)))))))
> +     s)
> +    escaped-string))

As a general comment, the coding style in Guix is functional =E2=80=9Cby
default=E2=80=9D (info "(guix) Coding Style").  That means we almost never =
use
=E2=80=98set!=E2=80=99 and procedures that modify their arguments.

We also avoid idioms like car/cdr and =E2=80=98do=E2=80=99, which are more =
commonly used
in other Lisps, as you know very well.  ;-)

In the case above, I=E2=80=99d probably use =E2=80=98string-fold=E2=80=99. =
 The resulting code
should be easier to reason about and likely more efficient.

> +(define (fetch-latest-version goproxy-url module-path)
> +  "Fetches the version number of the latest version for MODULE-PATH from=
 the
> +given GOPROXY-URL server."
> +  (assoc-ref
> +   (json-fetch (format #f "~a/~a/@latest" goproxy-url
> +                       (escape-capital-letters module-path)))
> +   "Version"))

I=E2=80=99d suggest using =E2=80=98define-json-mapping=E2=80=99 from (json)=
 like in the other
importers.

> +(define (infer-module-root module-path)
> +  "Go modules can be defined at any level of a repository's tree, but qu=
erying
> +for the meta tag usually can only be done at the webpage at the root of =
the
> +repository. Therefore, it is sometimes necessary to try and derive a mod=
ule's
> +root path from its path. For a set of well-known forges, the pattern of =
what
> +consists of a module's root page is known before hand."
> +  ;; See the following URL for the official Go equivalent:
> +  ;; https://github.com/golang/go/blob/846dce9d05f19a1f53465e62a304dea21=
b99f910/src/cmd/go/internal/vcs/vcs.go#L1026-L1087
> +  (define-record-type <scs>
> +    (make-scs url-prefix root-regex type)
> +    scs?
> +    (url-prefix	scs-url-prefix)
> +    (root-regex scs-root-regex)
> +    (type	scs-type))

Maybe VCS as =E2=80=9Cversion control system=E2=80=9D?  (It took me a while=
 to guess
what =E2=80=9CSCS=E2=80=9D meant.)

> +(define (fetch-module-meta-data module-path)
> +  "Fetches module meta-data from a module's landing page. This is necess=
ary
> +because goproxy servers don't currently provide all the information need=
ed to
> +build a package."
> +  (let* ((port (http-fetch (string->uri (format #f "https://~a?go-get=3D=
1" module-path))))
> +         (module-metadata #f)
> +         (meta-tag-prefix "<meta name=3D\"go-import\" content=3D\"")
> +         (meta-tag-prefix-length (string-length meta-tag-prefix)))
> +    (do ((line (read-line port) (read-line port)))
> +        ((or (eof-object? line)
> +             module-metadata))
> +      (let ((meta-tag-index (string-contains line meta-tag-prefix)))
> +        (when meta-tag-index
> +          (let* ((start (+ meta-tag-index meta-tag-prefix-length))
> +                 (end (string-index line #\" start)))
> +            (set! module-metadata
> +              (string-split (substring/shared line start end) #\space)))=
)))

I=E2=80=99d suggest a named =E2=80=98let=E2=80=99 or =E2=80=98fold=E2=80=99=
 here.

Likewise, instead of concatenating XML strings (which could lead to
malformed XML), I recommend using SXML: you would create an sexp like

  (meta (@ (name "go-import") (content =E2=80=A6)))

and at the end pass it to =E2=80=98sxml->sxml=E2=80=99 (info "(guile) Readi=
ng and
Writing XML").

> +    (else
> +     (raise-exception (format #f "unsupported scs type: ~a" scs-type)))))

=E2=80=98raise-exception=E2=80=99 takes an error condition.  In this case, =
we should use
(srfi srfi-34) for =E2=80=98raise=E2=80=99 write something like:

  (raise (condition (formatted-message (G_ "=E2=80=A6" =E2=80=A6))))

> +(define* (go-module->guix-package module-path #:key (goproxy-url "https:=
//proxy.golang.org"))
> +  (call-with-temporary-output-file
> +   (lambda (temp port)
> +     (let* ((latest-version (fetch-latest-version goproxy-url module-pat=
h))
> +            (go.mod-path (fetch-go.mod goproxy-url module-path latest-ve=
rsion
> +                                       temp))

It seems that =E2=80=98go.mod-path=E2=80=99 isn=E2=80=99t used, and thus =
=E2=80=98fetch-go.mod=E2=80=99 &
co. aren=E2=80=99t used either, or am I overlooking something?

> +            (dependencies (map car (parse-go.mod temp)))

Please use =E2=80=98match=E2=80=99 instead, or perhaps define a record type=
 for the
abstraction at hand.

> +            (guix-name (to-guix-package-name module-path))
> +            (root-module-path (infer-module-root module-path))
> +            ;; SCS type and URL are not included in goproxy information.=
 For
> +            ;; this we need to fetch it from the official module page.
> +            (meta-data (fetch-module-meta-data root-module-path))
> +            (scs-type (module-meta-data-scs meta-data))
> +            (scs-repo-url (module-meta-data-repo-url meta-data goproxy-u=
rl)))
> +       (values
> +        `(package
> +           (name ,guix-name)
> +           ;; Elide the "v" prefix Go uses
> +           (version ,(string-trim latest-version #\v))
> +           (source
> +            ,(source-uri scs-type scs-repo-url temp))
> +           (build-system go-build-system)
> +           ,@(maybe-inputs (map to-guix-package-name dependencies))
> +           ;; TODO(katco): It would be nice to make an effort to fetch t=
his
> +           ;; from known forges, e.g. GitHub
> +           (home-page ,(format #f "https://~a" root-module-path))
> +           (synopsis "A Go package")
> +           (description ,(format #f "~a is a Go package." guix-name))

Maybe something like =E2=80=9Cfill it out!=E2=80=9D so we don=E2=80=99t get=
 patch submissions
with the default synopsis/description.  :-)

> +           (license #f))

Likewise.

Two more things: could you (1) and an entry under =E2=80=9CInvoking guix im=
port=E2=80=9D
in doc/guix.texi, and (2) add tests, taking inspiration from the
existing importer tests?

Thank you!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#44178; Package guix-patches. Full text available.

Message received at 44178 <at> debbugs.gnu.org:


Received: (at 44178) by debbugs.gnu.org; 28 Oct 2020 10:41:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Oct 28 06:41:55 2020
Received: from localhost ([127.0.0.1]:47330 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kXitv-0003EJ-6V
	for submit <at> debbugs.gnu.org; Wed, 28 Oct 2020 06:41:55 -0400
Received: from eggs.gnu.org ([209.51.188.92]:38518)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1kXitt-0003E8-PQ
 for 44178 <at> debbugs.gnu.org; Wed, 28 Oct 2020 06:41:54 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:41106)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1kXito-0003nQ-FO; Wed, 28 Oct 2020 06:41:48 -0400
Received: from vpn-0-27.aquilenet.fr ([2a0c:e300:4:27::]:38490 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1kXitn-000517-RP; Wed, 28 Oct 2020 06:41:48 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Katherine Cox-Buday <cox.katherine.e@HIDDEN>
Subject: Re: [bug#44178] Add a Go Module Importer
References: <87sga5kpdp.fsf@HIDDEN>
Date: Wed, 28 Oct 2020 11:41:45 +0100
In-Reply-To: <87sga5kpdp.fsf@HIDDEN> (Katherine Cox-Buday's message of
 "Fri, 23 Oct 2020 09:06:58 -0500")
Message-ID: <87a6w64opi.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 44178
Cc: 44178 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi Katherine,

Katherine Cox-Buday <cox.katherine.e@HIDDEN> skribis:

>>From cc92cbcf5ae89891f478f319e955419800bdfcf9 Mon Sep 17 00:00:00 2001
> From: Katherine Cox-Buday <cox.katherine.e@HIDDEN>
> Date: Thu, 22 Oct 2020 19:40:17 -0500
> Subject: [PATCH] * guix/import/go.scm: Created Go Importer *
>  guix/scripts/import.scm: Created Go Importer Subcommand * guix/import/go=
.scm
>  (importers): Added Go Importer Subcommand

Nice!  I think that can make a lot of people happy.  :-)

Here=E2=80=99s a quick review.  I won=E2=80=99t promise I can reply to foll=
owups in the
coming days because with the release preparation going on, I=E2=80=99d rath=
er
focus on that.  So perhaps this patch will have to wait until after this
release, but certainly before the next one!

> +(define (escape-capital-letters s)
> +  "To avoid ambiguity when serving from case-insensitive file systems, t=
he
> +$module and $version elements are case-encoded by replacing every upperc=
ase
> +letter with an exclamation mark followed by the corresponding lower-case
> +letter."
> +  (let ((escaped-string (string)))
> +    (string-for-each-index
> +     (lambda (i)
> +       (let ((c (string-ref s i)))
> +         (set! escaped-string
> +           (string-concatenate
> +            (list escaped-string
> +                  (if (char-upper-case? c) "!" "")
> +                  (string (char-downcase c)))))))
> +     s)
> +    escaped-string))

As a general comment, the coding style in Guix is functional =E2=80=9Cby
default=E2=80=9D (info "(guix) Coding Style").  That means we almost never =
use
=E2=80=98set!=E2=80=99 and procedures that modify their arguments.

We also avoid idioms like car/cdr and =E2=80=98do=E2=80=99, which are more =
commonly used
in other Lisps, as you know very well.  ;-)

In the case above, I=E2=80=99d probably use =E2=80=98string-fold=E2=80=99. =
 The resulting code
should be easier to reason about and likely more efficient.

> +(define (fetch-latest-version goproxy-url module-path)
> +  "Fetches the version number of the latest version for MODULE-PATH from=
 the
> +given GOPROXY-URL server."
> +  (assoc-ref
> +   (json-fetch (format #f "~a/~a/@latest" goproxy-url
> +                       (escape-capital-letters module-path)))
> +   "Version"))

I=E2=80=99d suggest using =E2=80=98define-json-mapping=E2=80=99 from (json)=
 like in the other
importers.

> +(define (infer-module-root module-path)
> +  "Go modules can be defined at any level of a repository's tree, but qu=
erying
> +for the meta tag usually can only be done at the webpage at the root of =
the
> +repository. Therefore, it is sometimes necessary to try and derive a mod=
ule's
> +root path from its path. For a set of well-known forges, the pattern of =
what
> +consists of a module's root page is known before hand."
> +  ;; See the following URL for the official Go equivalent:
> +  ;; https://github.com/golang/go/blob/846dce9d05f19a1f53465e62a304dea21=
b99f910/src/cmd/go/internal/vcs/vcs.go#L1026-L1087
> +  (define-record-type <scs>
> +    (make-scs url-prefix root-regex type)
> +    scs?
> +    (url-prefix	scs-url-prefix)
> +    (root-regex scs-root-regex)
> +    (type	scs-type))

Maybe VCS as =E2=80=9Cversion control system=E2=80=9D?  (It took me a while=
 to guess
what =E2=80=9CSCS=E2=80=9D meant.)

> +(define (fetch-module-meta-data module-path)
> +  "Fetches module meta-data from a module's landing page. This is necess=
ary
> +because goproxy servers don't currently provide all the information need=
ed to
> +build a package."
> +  (let* ((port (http-fetch (string->uri (format #f "https://~a?go-get=3D=
1" module-path))))
> +         (module-metadata #f)
> +         (meta-tag-prefix "<meta name=3D\"go-import\" content=3D\"")
> +         (meta-tag-prefix-length (string-length meta-tag-prefix)))
> +    (do ((line (read-line port) (read-line port)))
> +        ((or (eof-object? line)
> +             module-metadata))
> +      (let ((meta-tag-index (string-contains line meta-tag-prefix)))
> +        (when meta-tag-index
> +          (let* ((start (+ meta-tag-index meta-tag-prefix-length))
> +                 (end (string-index line #\" start)))
> +            (set! module-metadata
> +              (string-split (substring/shared line start end) #\space)))=
)))

I=E2=80=99d suggest a named =E2=80=98let=E2=80=99 or =E2=80=98fold=E2=80=99=
 here.

Likewise, instead of concatenating XML strings (which could lead to
malformed XML), I recommend using SXML: you would create an sexp like

  (meta (@ (name "go-import") (content =E2=80=A6)))

and at the end pass it to =E2=80=98sxml->sxml=E2=80=99 (info "(guile) Readi=
ng and
Writing XML").

> +    (else
> +     (raise-exception (format #f "unsupported scs type: ~a" scs-type)))))

=E2=80=98raise-exception=E2=80=99 takes an error condition.  In this case, =
we should use
(srfi srfi-34) for =E2=80=98raise=E2=80=99 write something like:

  (raise (condition (formatted-message (G_ "=E2=80=A6" =E2=80=A6))))

> +(define* (go-module->guix-package module-path #:key (goproxy-url "https:=
//proxy.golang.org"))
> +  (call-with-temporary-output-file
> +   (lambda (temp port)
> +     (let* ((latest-version (fetch-latest-version goproxy-url module-pat=
h))
> +            (go.mod-path (fetch-go.mod goproxy-url module-path latest-ve=
rsion
> +                                       temp))

It seems that =E2=80=98go.mod-path=E2=80=99 isn=E2=80=99t used, and thus =
=E2=80=98fetch-go.mod=E2=80=99 &
co. aren=E2=80=99t used either, or am I overlooking something?

> +            (dependencies (map car (parse-go.mod temp)))

Please use =E2=80=98match=E2=80=99 instead, or perhaps define a record type=
 for the
abstraction at hand.

> +            (guix-name (to-guix-package-name module-path))
> +            (root-module-path (infer-module-root module-path))
> +            ;; SCS type and URL are not included in goproxy information.=
 For
> +            ;; this we need to fetch it from the official module page.
> +            (meta-data (fetch-module-meta-data root-module-path))
> +            (scs-type (module-meta-data-scs meta-data))
> +            (scs-repo-url (module-meta-data-repo-url meta-data goproxy-u=
rl)))
> +       (values
> +        `(package
> +           (name ,guix-name)
> +           ;; Elide the "v" prefix Go uses
> +           (version ,(string-trim latest-version #\v))
> +           (source
> +            ,(source-uri scs-type scs-repo-url temp))
> +           (build-system go-build-system)
> +           ,@(maybe-inputs (map to-guix-package-name dependencies))
> +           ;; TODO(katco): It would be nice to make an effort to fetch t=
his
> +           ;; from known forges, e.g. GitHub
> +           (home-page ,(format #f "https://~a" root-module-path))
> +           (synopsis "A Go package")
> +           (description ,(format #f "~a is a Go package." guix-name))

Maybe something like =E2=80=9Cfill it out!=E2=80=9D so we don=E2=80=99t get=
 patch submissions
with the default synopsis/description.  :-)

> +           (license #f))

Likewise.

Two more things: could you (1) and an entry under =E2=80=9CInvoking guix im=
port=E2=80=9D
in doc/guix.texi, and (2) add tests, taking inspiration from the
existing importer tests?

Thank you!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#44178; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 23 Oct 2020 14:07:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 23 10:07:14 2020
Received: from localhost ([127.0.0.1]:57927 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kVxin-0007cI-I6
	for submit <at> debbugs.gnu.org; Fri, 23 Oct 2020 10:07:14 -0400
Received: from lists.gnu.org ([209.51.188.17]:53784)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <cox.katherine.e@HIDDEN>) id 1kVxil-0007cA-0o
 for submit <at> debbugs.gnu.org; Fri, 23 Oct 2020 10:07:07 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:36654)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <cox.katherine.e@HIDDEN>)
 id 1kVxik-0000iM-Rx
 for guix-patches@HIDDEN; Fri, 23 Oct 2020 10:07:06 -0400
Received: from mail-il1-x130.google.com ([2607:f8b0:4864:20::130]:41332)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <cox.katherine.e@HIDDEN>)
 id 1kVxii-0007AU-26
 for guix-patches@HIDDEN; Fri, 23 Oct 2020 10:07:06 -0400
Received: by mail-il1-x130.google.com with SMTP id w17so1461012ilg.8
 for <guix-patches@HIDDEN>; Fri, 23 Oct 2020 07:07:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:subject:date:message-id:user-agent:mime-version;
 bh=uyjhv6K/f097J75OsRfsyDtv4uU4brSBk+/EuWxGjPI=;
 b=qDOpGWxL8hmmEXsmarrpLyyVRNsgle6lHQ4SUFxfWMOMpXoGhrP5Y/YIVOMz7WOSje
 gGq41lpWnLzP3wvZFIN3KMdT7H9lrpjjLQg+Ue5BzDrvmVN1+uouoARfpuVhLpZFIMao
 q4qMjqJh3MghTAUXIL6nHsMJKj+lhLPHLRLuDDZv4paZ91gKLmqePqjZSgDRvYTijFZ/
 6toIr7QDexToUVMfTzMq80iU5eX9cIh0BuI/Gqn1Q4fEbA7WS+xuycolQ6d4RcWERCIm
 JSRJ8QGU5QWiyn0vTS8wn+UBwtDi1LdkGt9x5oyQQMTtA+28Ji8VnWdrHQ91F6hNqg6a
 mAEA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:date:message-id:user-agent
 :mime-version;
 bh=uyjhv6K/f097J75OsRfsyDtv4uU4brSBk+/EuWxGjPI=;
 b=Pnu9svffzmMftqOwmTZ6eCFDhhfqwOTmL8K+WkMideHSyKLr0OOen8PQTbG5DazhkA
 7HJZdoSCgL/zRu/DoEZICAbP2JAWJMFZG7tAsbuZRF1GjQZFZhFDP8U6Bi667X4ZZwDP
 9bKMax5yEZpDuGPI8k+3klmS6Ebch+lKAtxz/cDB5C38jJBmP7UairJ4wFmxHB0tzWR1
 nQEbTj0Pb/+QqHCls2CfKyuD1+nSGgCZ0iMARFg3fFRGi61hhjKx+AhVp1L9zAiGze+3
 xvXh6ib3Ym8M7YVcEjRpqcFVLt7hnwpcXH2J0bUjuJiVg651ss+Md7t0RedwFrxoyPkO
 SdWg==
X-Gm-Message-State: AOAM530Sq1WGVwZPFV1PInVcPLZTgjgHC7JUcluWEBPHPK0V6AbepHB9
 JFn02I+eX5TOpf0Vgj65P85HqM5h9D/t4Q==
X-Google-Smtp-Source: ABdhPJwfzRxnccMMmCEJl4PzPVrYqW/IrhfFCoRkp+SxEa1zSFBA/pskk0kbXrJGJrT3j21fWovYFQ==
X-Received: by 2002:a92:d28b:: with SMTP id p11mr1841370ilp.264.1603462020810; 
 Fri, 23 Oct 2020 07:07:00 -0700 (PDT)
Received: from washu-v4 (172-221-246-205.res.spectrum.com. [172.221.246.205])
 by smtp.gmail.com with ESMTPSA id
 g26sm692059ion.25.2020.10.23.07.06.59 for <guix-patches@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 23 Oct 2020 07:06:59 -0700 (PDT)
From: Katherine Cox-Buday <cox.katherine.e@HIDDEN>
To: guix-patches@HIDDEN
Subject: Add a Go Module Importer
Date: Fri, 23 Oct 2020 09:06:58 -0500
Message-ID: <87sga5kpdp.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=2607:f8b0:4864:20::130;
 envelope-from=cox.katherine.e@HIDDEN; helo=mail-il1-x130.google.com
X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache.
 That's all we know.
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/x-patch; charset=utf-8
Content-Disposition: inline;
 filename=0001-guix-import-go.scm-Created-Go-Importer.patch
Content-Transfer-Encoding: quoted-printable

From cc92cbcf5ae89891f478f319e955419800bdfcf9 Mon Sep 17 00:00:00 2001
From: Katherine Cox-Buday <cox.katherine.e@HIDDEN>
Date: Thu, 22 Oct 2020 19:40:17 -0500
Subject: [PATCH] * guix/import/go.scm: Created Go Importer *
 guix/scripts/import.scm: Created Go Importer Subcommand * guix/import/go.s=
cm
 (importers): Added Go Importer Subcommand

---
 guix/import/go.scm         | 276 +++++++++++++++++++++++++++++++++++++
 guix/scripts/import.scm    |   2 +-
 guix/scripts/import/go.scm | 118 ++++++++++++++++
 3 files changed, 395 insertions(+), 1 deletion(-)
 create mode 100644 guix/import/go.scm
 create mode 100644 guix/scripts/import/go.scm

diff --git a/guix/import/go.scm b/guix/import/go.scm
new file mode 100644
index 0000000000..61009f3565
--- /dev/null
+++ b/guix/import/go.scm
@@ -0,0 +1,276 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright =C2=A9 2020 Katherine Cox-Buday <cox.katherine.e@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix import go)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 rdelim)
+  #:use-module (ice-9 receive)
+  #:use-module (ice-9 regex)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-9)
+  #:use-module (guix json)
+  #:use-module ((guix download) #:prefix download:)
+  #:use-module (guix import utils)
+  #:use-module (guix import json)
+  #:use-module (guix packages)
+  #:use-module (guix upstream)
+  #:use-module (guix utils)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix base16)
+  #:use-module (guix base32)
+  #:use-module (guix build download)
+  #:use-module (web uri)
+
+  #:export (go-module->guix-package
+            go-module-recursive-import
+            infer-module-root))
+
+(define (escape-capital-letters s)
+  "To avoid ambiguity when serving from case-insensitive file systems, the
+$module and $version elements are case-encoded by replacing every uppercase
+letter with an exclamation mark followed by the corresponding lower-case
+letter."
+  (let ((escaped-string (string)))
+    (string-for-each-index
+     (lambda (i)
+       (let ((c (string-ref s i)))
+         (set! escaped-string
+           (string-concatenate
+            (list escaped-string
+                  (if (char-upper-case? c) "!" "")
+                  (string (char-downcase c)))))))
+     s)
+    escaped-string))
+
+(define (fetch-latest-version goproxy-url module-path)
+  "Fetches the version number of the latest version for MODULE-PATH from t=
he
+given GOPROXY-URL server."
+  (assoc-ref
+   (json-fetch (format #f "~a/~a/@latest" goproxy-url
+                       (escape-capital-letters module-path)))
+   "Version"))
+
+(define (fetch-go.mod goproxy-url module-path version file)
+  "Fetches go.mod from the given GOPROXY-URL server for the given MODULE-P=
ATH
+and VERSION."
+  (url-fetch (format #f "~a/~a/@v/~a.mod" goproxy-url
+                     (escape-capital-letters module-path)
+                     (escape-capital-letters version))
+             file
+             #:print-build-trace? #f))
+
+(define (parse-go.mod go.mod-path)
+  "Parses a go.mod file and returns an alist of module path to version."
+  (with-input-from-file go.mod-path
+    (lambda ()
+      (let ((in-require? #f)
+            (requirements (list)))
+        (do ((line (read-line) (read-line)))
+            ((eof-object? line))
+          (set! line (string-trim line))
+          ;; The parser is either entering, within, exiting, or after the
+          ;; require block. The Go toolchain is trustworthy so edge-cases =
like
+          ;; double-entry, etc. need not complect the parser.
+          (cond
+           ((string=3D? line "require (")
+            (set! in-require? #t))
+           ((and in-require? (string=3D? line ")"))
+            (set! in-require? #f))
+           (in-require?
+            (let* ((requirement (string-split line #\space))
+                   ;; Modules should be unquoted
+                   (module-path (string-delete #\" (car requirement)))
+                   (version (list-ref requirement 1)))
+              (set! requirements (acons module-path version requirements))=
))
+           ((string-prefix? "replace" line)
+            (let* ((requirement (string-split line #\space))
+                   (module-path (list-ref requirement 1))
+                   (new-module-path (list-ref requirement 3))
+                   (version (list-ref requirement 4)))
+              (set! requirements (assoc-remove! requirements module-path))
+              (set! requirements (acons new-module-path version requiremen=
ts))))))
+        requirements))))
+
+(define (module-path-without-major-version module-path)
+  "Go modules can be appended with a major version indicator,
+e.g. /v3. Sometimes it is desirable to work with the root module path. For
+instance, for a module path github.com/foo/bar/v3 this function returns
+github.com/foo/bar."
+  (let ((m (string-match "(.*)\\/v[0-9]+$" module-path)))
+    (if m
+        (match:substring m 1)
+        module-path)))
+
+(define (infer-module-root module-path)
+  "Go modules can be defined at any level of a repository's tree, but quer=
ying
+for the meta tag usually can only be done at the webpage at the root of the
+repository. Therefore, it is sometimes necessary to try and derive a modul=
e's
+root path from its path. For a set of well-known forges, the pattern of wh=
at
+consists of a module's root page is known before hand."
+  ;; See the following URL for the official Go equivalent:
+  ;; https://github.com/golang/go/blob/846dce9d05f19a1f53465e62a304dea21b9=
9f910/src/cmd/go/internal/vcs/vcs.go#L1026-L1087
+  (define-record-type <scs>
+    (make-scs url-prefix root-regex type)
+    scs?
+    (url-prefix	scs-url-prefix)
+    (root-regex scs-root-regex)
+    (type	scs-type))
+  (let* ((known-scs
+          (list
+           (make-scs
+            "github.com"
+            "^(github\\.com/[A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+)(/[A-Za-z0=
-9_.\\-]+)*$"
+            'git)
+           (make-scs
+            "bitbucket.org"
+            "^(bitbucket\\.org/([A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+))(/[A-=
Za-z0-9_.\\-]+)*$`"
+            'unknown)
+           (make-scs
+            "hub.jazz.net/git/"
+            "^(hub\\.jazz\\.net/git/[a-z0-9]+/[A-Za-z0-9_.\\-]+)(/[A-Za-z0=
-9_.\\-]+)*$"
+            'git)
+           (make-scs
+            "git.apache.org"
+            "^(git\\.apache\\.org/[a-z0-9_.\\-]+\\.git)(/[A-Za-z0-9_.\\-]+=
)*$"
+            'git)
+           (make-scs
+            "git.openstack.org"
+            "^(git\\.openstack\\.org/[A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+)(=
\\.git)?(/[A-Za-z0-9_.\\-]+)*$"
+            'git)))
+         (scs (find (lambda (scs) (string-prefix? (scs-url-prefix scs) mod=
ule-path))
+                    known-scs)))
+    (if scs
+        (match:substring (string-match (scs-root-regex scs) module-path) 1)
+        module-path)))
+
+(define (to-guix-package-name module-path)
+  "Converts a module's path to the canonical Guix format for Go packages."
+  (string-downcase
+   (string-append "go-"
+                  (string-replace-substring
+                   (string-replace-substring
+                    ;; Guix has its own field for version
+                    (module-path-without-major-version module-path)
+                    "." "-")
+                   "/" "-"))))
+
+(define (fetch-module-meta-data module-path)
+  "Fetches module meta-data from a module's landing page. This is necessary
+because goproxy servers don't currently provide all the information needed=
 to
+build a package."
+  (let* ((port (http-fetch (string->uri (format #f "https://~a?go-get=3D1"=
 module-path))))
+         (module-metadata #f)
+         (meta-tag-prefix "<meta name=3D\"go-import\" content=3D\"")
+         (meta-tag-prefix-length (string-length meta-tag-prefix)))
+    (do ((line (read-line port) (read-line port)))
+        ((or (eof-object? line)
+             module-metadata))
+      (let ((meta-tag-index (string-contains line meta-tag-prefix)))
+        (when meta-tag-index
+          (let* ((start (+ meta-tag-index meta-tag-prefix-length))
+                 (end (string-index line #\" start)))
+            (set! module-metadata
+              (string-split (substring/shared line start end) #\space))))))
+    (close-port port)
+    module-metadata))
+
+(define (module-meta-data-scs meta-data)
+  "Return the source control system specified by a module's meta-data."
+  (string->symbol (list-ref meta-data 1)))
+
+(define (module-meta-data-repo-url meta-data goproxy-url)
+  "Return the URL where the fetcher which will be used can download the so=
urce
+control."
+  (if (member (module-meta-data-scs meta-data) '(fossil mod))
+      goproxy-url
+      (list-ref meta-data 2)))
+
+(define (source-uri scs-type scs-repo-url file)
+  "Generate the `origin' block of a package depending on what type of sour=
ce
+control system is being used."
+  (case scs-type
+    ((git)
+     `(origin
+        (method git-fetch)
+        (uri (git-reference
+              (url ,scs-repo-url)
+              (commit (string-append "v" version))))
+        (file-name (git-file-name name version))
+        (sha256
+         (base32
+          ,(guix-hash-url file)))))
+    ((hg)
+     `(origin
+        (method hg-fetch)
+        (uri (hg-reference
+              (url ,scs-repo-url)
+              (changeset ,version)))
+        (file-name (format #f "~a-~a-checkout" name version))))
+    ((svn)
+     `(origin
+        (method svn-fetch)
+        (uri (svn-reference
+              (url ,scs-repo-url)
+              (revision (string->number version))
+              (recursive? #f)))
+        (file-name (format #f "~a-~a-checkout" name version))
+        (sha256
+         (base32
+          ,(guix-hash-url file)))))
+    (else
+     (raise-exception (format #f "unsupported scs type: ~a" scs-type)))))
+
+(define* (go-module->guix-package module-path #:key (goproxy-url "https://=
proxy.golang.org"))
+  (call-with-temporary-output-file
+   (lambda (temp port)
+     (let* ((latest-version (fetch-latest-version goproxy-url module-path))
+            (go.mod-path (fetch-go.mod goproxy-url module-path latest-vers=
ion
+                                       temp))
+            (dependencies (map car (parse-go.mod temp)))
+            (guix-name (to-guix-package-name module-path))
+            (root-module-path (infer-module-root module-path))
+            ;; SCS type and URL are not included in goproxy information. F=
or
+            ;; this we need to fetch it from the official module page.
+            (meta-data (fetch-module-meta-data root-module-path))
+            (scs-type (module-meta-data-scs meta-data))
+            (scs-repo-url (module-meta-data-repo-url meta-data goproxy-url=
)))
+       (values
+        `(package
+           (name ,guix-name)
+           ;; Elide the "v" prefix Go uses
+           (version ,(string-trim latest-version #\v))
+           (source
+            ,(source-uri scs-type scs-repo-url temp))
+           (build-system go-build-system)
+           ,@(maybe-inputs (map to-guix-package-name dependencies))
+           ;; TODO(katco): It would be nice to make an effort to fetch this
+           ;; from known forges, e.g. GitHub
+           (home-page ,(format #f "https://~a" root-module-path))
+           (synopsis "A Go package")
+           (description ,(format #f "~a is a Go package." guix-name))
+           (license #f))
+        dependencies)))))
+
+(define* (go-module-recursive-import package-name
+                                     #:key (goproxy-url "https://proxy.gol=
ang.org"))
+  (recursive-import package-name #f
+                    #:repo->guix-package
+                    (lambda (name _)
+                      (go-module->guix-package name
+                                               #:goproxy-url goproxy-url))
+                    #:guix-name to-guix-package-name))
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index 0a3863f965..1d2b45d942 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -77,7 +77,7 @@ rather than \\n."
 ;;;
=20
 (define importers '("gnu" "nix" "pypi" "cpan" "hackage" "stackage" "elpa" =
"gem"
-                    "cran" "crate" "texlive" "json" "opam"))
+                    "go" "cran" "crate" "texlive" "json" "opam"))
=20
 (define (resolve-importer name)
   (let ((module (resolve-interface
diff --git a/guix/scripts/import/go.scm b/guix/scripts/import/go.scm
new file mode 100644
index 0000000000..000039769c
--- /dev/null
+++ b/guix/scripts/import/go.scm
@@ -0,0 +1,118 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright =C2=A9 2020 Katherine Cox-Buday <cox.katherine.e@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix scripts import go)
+  #:use-module (guix ui)
+  #:use-module (guix utils)
+  #:use-module (guix scripts)
+  #:use-module (guix import go)
+  #:use-module (guix scripts import)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-11)
+  #:use-module (srfi srfi-37)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 format)
+  #:export (guix-import-go))
+
+
+;;;
+;;; Command-line options.
+;;;
+
+(define %default-options
+  '())
+
+(define (show-help)
+  (display (G_ "Usage: guix import go PACKAGE-PATH
+Import and convert the Go module for PACKAGE-PATH.\n"))
+  (display (G_ "
+  -h, --help             display this help and exit"))
+  (display (G_ "
+  -V, --version          display version information and exit"))
+  (display (G_ "
+  -r, --recursive        generate package expressions for all Go modules\
+ that are not yet in Guix"))
+  (display (G_ "
+  -p, --goproxy=3DGOPROXY  specify which goproxy server to use"))
+  (newline)
+  (show-bug-report-information))
+
+(define %options
+  ;; Specification of the command-line options.
+  (cons* (option '(#\h "help") #f #f
+                 (lambda args
+                   (show-help)
+                   (exit 0)))
+         (option '(#\V "version") #f #f
+                 (lambda args
+                   (show-version-and-exit "guix import go")))
+         (option '(#\r "recursive") #f #f
+                 (lambda (opt name arg result)
+                   (alist-cons 'recursive #t result)))
+         (option '(#\p "goproxy") #t #f
+                 (lambda (opt name arg result)
+                   (alist-cons 'goproxy
+                               (string->symbol arg)
+                               (alist-delete 'goproxy result))))
+         %standard-import-options))
+
+
+;;;
+;;; Entry point.
+;;;
+
+(define (guix-import-go . args)
+  (define (parse-options)
+    ;; Return the alist of option values.
+    (args-fold* args %options
+                (lambda (opt name arg result)
+                  (leave (G_ "~A: unrecognized option~%") name))
+                (lambda (arg result)
+                  (alist-cons 'argument arg result))
+                %default-options))
+
+  (let* ((opts (parse-options))
+         (args (filter-map (match-lambda
+                             (('argument . value)
+                              value)
+                             (_ #f))
+                           (reverse opts))))
+    (match args
+      ((module-name)
+       (if (assoc-ref opts 'recursive)
+           (map (match-lambda
+                  ((and ('package ('name name) . rest) pkg)
+                   `(define-public ,(string->symbol name)
+                      ,pkg))
+                  (_ #f))
+                (go-module-recursive-import module-name
+                                            #:goproxy-url
+                                            (or (assoc-ref opts 'goproxy)
+                                                "https://proxy.golang.org"=
)))
+           (let ((sexp (go-module->guix-package module-name
+                                                #:goproxy-url
+                                                (or (assoc-ref opts 'gopro=
xy)
+                                                    "https://proxy.golang.=
org"))))
+             (unless sexp
+               (leave (G_ "failed to download meta-data for module '~a'~%")
+                      module-name))
+             sexp)))
+      (()
+       (leave (G_ "too few arguments~%")))
+      ((many ...)
+       (leave (G_ "too many arguments~%"))))))
--=20
2.28.0


--=-=-=
Content-Type: text/plain


-- 
Katherine

--=-=-=--




Acknowledgement sent to Katherine Cox-Buday <cox.katherine.e@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#44178; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 11 Nov 2020 21:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.