From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id KGbkKHru9GDs0gAAgWs5BA (envelope-from ) for ; Mon, 19 Jul 2021 05:16:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id uKCbJHru9GDdZAAAB5/wlQ (envelope-from ) for ; Mon, 19 Jul 2021 03:16:10 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CB26D9BF0 for ; Mon, 19 Jul 2021 05:16:09 +0200 (CEST) Received: from localhost ([::1]:39358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5JlI-0004zj-UC for larch@yhetil.org; Sun, 18 Jul 2021 23:16:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5JlD-0004zH-01 for guix-patches@gnu.org; Sun, 18 Jul 2021 23:16:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46208) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m5JlC-0001wP-Mj for guix-patches@gnu.org; Sun, 18 Jul 2021 23:16:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m5JlC-0000oO-6Z for guix-patches@gnu.org; Sun, 18 Jul 2021 23:16:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49602] [PATCH] import: go: Upgrade go.mod parser. Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 19 Jul 2021 03:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49602 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 49602@debbugs.gnu.org Received: via spool by 49602-submit@debbugs.gnu.org id=B49602.16266645123059 (code B ref 49602); Mon, 19 Jul 2021 03:16:02 +0000 Received: (at 49602) by debbugs.gnu.org; 19 Jul 2021 03:15:12 +0000 Received: from localhost ([127.0.0.1]:57753 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m5JkN-0000nG-RI for submit@debbugs.gnu.org; Sun, 18 Jul 2021 23:15:12 -0400 Received: from out2.migadu.com ([188.165.223.204]:20776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m5JkJ-0000n0-7s for 49602@debbugs.gnu.org; Sun, 18 Jul 2021 23:15:10 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1626664505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6gyxth01K+89CTPi3Iajt32JExWuX6nUO0ITq0Jgi3Q=; b=PMzirhEioQRGxb+W0UQEEvDxcXp9O/dCIaYDJPZAzQrhy7LNsNAaYhijvuFd1XCHO0Ohb7 xaCWZDL7my9A1RHicA7uA8MaKobEeKP6qLNa412G94sJJDJdkEZvwyV700YQf9KiFdLk6c Ao8XwpBxg15+kgqwPvo1WW4UqyYus3U= From: Sarah Morgensen References: <8a452809f56c9b62b46a7639ff89148ffc845b3e.1626493564.git.iskarian@mgsn.dev> <87tuksjh68.fsf@gmail.com> Date: Sun, 18 Jul 2021 20:15:03 -0700 In-Reply-To: <87tuksjh68.fsf@gmail.com> (Maxim Cournoyer's message of "Sun, 18 Jul 2021 01:59:43 -0400") Message-ID: <86eebvt2o8.fsf@mgsn.dev> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Auth-User: iskarian@mgsn.dev X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1626664570; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=6gyxth01K+89CTPi3Iajt32JExWuX6nUO0ITq0Jgi3Q=; b=ADs/jyM5o+IkOgMXyrmGl93s35tGJ6hWTGiksgWH3yQ89yk4m4CjPMK6DXQ3gYs6ZB82C7 9U0TDyHBEF5JfBzVNFWf4JKQri+AX5q5FIke5eNxhUw0CjKNLXyaIBTScmz9hbrKDrArQD rD593xFVTKQp+W/J7MoGtwiXj0Jwkd2F5Mu9fbkkuAsX1D8T+fb6L4THyvqe9dM6PjCdkb up0HMthePVKmSXNXt0MzcDbGmc6T2kCSRPcJvdQy/XjBNrcDI00fwDl0shwnqbSiENu21O ka19UM1HE4iKxKf/F1wl9akppfmwwyLbz+QSZCeZUZhL03DLss6m0FdbT8lXKw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1626664570; a=rsa-sha256; cv=none; b=JBrpv1FfEPnD1PSn4973VaOIpJWJIpqp2dp7nUB0CKamGM64ImCDPzfyTKq+nb/rnal6jU 4KzSDYCtf23QBunlWXi9gT5RYqGl9C5RHNR3MxXoZ7oBWfriJv6Ld0JLzJ+MUe++SS4XRr bYZX+NnSZMSnaoZZu9oInO1qNc79mKTdrUaqOy/QvqsJn7zd8uNPTfzlvIBNeJ8ZDFZ5fS yvg7S+IJ1pEOTlwvc0H6iZuz2yLa1C5e4I9sQIKpJ0DT6dRc7BRe69AcVtDoDIQKOsPUOH WJ2jc/mNG3vvwV0VG9oENAAa2LZSiBS6vUUnpXIf7acBWCMt611uCq9fxcUcIA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=PMzirhEi; dmarc=fail reason="SPF not aligned (relaxed)" header.from=mgsn.dev (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.31 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=PMzirhEi; dmarc=fail reason="SPF not aligned (relaxed)" header.from=mgsn.dev (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: CB26D9BF0 X-Spam-Score: -1.31 X-Migadu-Scanner: scn1.migadu.com X-TUID: /dDPbEt4ZK+S Hello, Thanks for the review :) I just knew I wouldn't get that long commit message right the first time! Maxim Cournoyer writes: >> (%go.mod-require-directive-rx) > > The above line can be removed, as it is duplicated below. > >> (%go.mod-replace-directive-rx): Remove unused variable. Those are actually two distinct variables ("...-require-..." vs "...-replace-..."), though I should've written "variables." >> + (define-peg-pattern string-or-ident body > ^ > Perhaps prefer the fully spelled out 'string-or-identifier' variable name. > Agree. >> +(define (go.mod-requirements go.mod) >> + "Compute and return the list of requirements specified by GO.MOD." >> + (define (replace directive requirements) >> + (define (maybe-replace module-path new-requirement) >> + ;; Do not allow version updates for indirect dependencies >> + ;; TODO: Is this correct behavior? It's in the go.mod for a >> reason... > > According to [1], it seems that yes: "replace directives only apply in > the main module's go.mod file and are ignored in other modules.", IIUC. > > [1] https://golang.org/ref/mod#go-mod-file-replace > My read of it is that if module A requires module B, replace directives in B's go.mod are ignored, but A's go.mod can replace any module, direct or indirect. For example, if module B hasn't been updated, but the version of module C it depends on has a bug that affects it, module A can use a replace in it's go.mod without requiring an upstream update of module B. To be fair, this is usually handled by specifying the indirect dependency with a specific version as a requirement in module A's go.mod, but the replace should be valid as well. The reason it was skipped before, I think (if it was intentional), is that since we only have the one version of a module in Guix at a time, it's not necessary to make the indirect dependency explicitly an input, so don't include it. On the other hand, if it *was* used to avoid a bug in a version used by an indirect dependency, wouldn't we want to make sure the Guix package was the fixed version? This is why I was questioning whether leaving it out was correct. > Pushed with commit 793ba333c6, after fixing up some indents and > substituting the TODO for an explanatory comment with a reference to the > replace directive, and a few more cosmetic changes. Thanks for the final touches. > Thanks for the continued improvements to the Go importer :-). Happy to help :) Originally, I was just trying to package a Go program, and look what happened... -- Sarah