[go] cmd/go: include 'dist' in 'go tool' list

4 views
Skip to first unread message

rui xi (Gerrit)

unread,
Jul 15, 2026, 4:45:04 AM (7 days ago) Jul 15
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

rui xi has uploaded the change for review

Commit message

cmd/go: include 'dist' in 'go tool' list

Some environments remove the 'dist' binary from the toolchain to
save space, as it is primarily needed for building the toolchain itself.
However, 'go tool' users expect it to be listed as a known tool,
especially since 'go tool dist list' remains functional via
internal impersonation.

This change ensures that 'dist' is included in the list displayed
by 'go tool' even when the binary is not physically present in
the tool directory.
Change-Id: I0446af11fc96974ade3c424c486f0738d12c5be8

Change diff

diff --git a/src/cmd/go/internal/tool/tool.go b/src/cmd/go/internal/tool/tool.go
index 97c27c8..81b0a16 100644
--- a/src/cmd/go/internal/tool/tool.go
+++ b/src/cmd/go/internal/tool/tool.go
@@ -159,6 +159,21 @@
return
}

+ // cmd/distpack removes the 'dist' tool from the toolchain to save space,
+ // as it is only needed for building the toolchain. However, 'go tool'
+ // users expect it to be listed as a known tool. If it is missing,
+ // manually add it to the list.
+ hasDist := false
+ for _, n := range names {
+ if strings.TrimSuffix(strings.ToLower(n), cfg.ToolExeSuffix()) == "dist" {
+ hasDist = true
+ break
+ }
+ }
+ if !hasDist {
+ names = append(names, "dist")
+ }
+
ambiguous := make(map[string]bool) // names that can't be used as aliases because they are ambiguous
sort.Strings(names)
for _, name := range names {

Change information

Files:
  • M src/cmd/go/internal/tool/tool.go
Change size: S
Delta: 1 file changed, 15 insertions(+), 0 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I0446af11fc96974ade3c424c486f0738d12c5be8
Gerrit-Change-Number: 800840
Gerrit-PatchSet: 1
Gerrit-Owner: rui xi <ruixir...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Gopher Robot (Gerrit)

unread,
Jul 15, 2026, 4:50:06 AM (7 days ago) Jul 15
to rui xi, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Message from Gopher Robot

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11 or adds a tag like "wait-release", it means that this CL will be
reviewed as part of the next development cycle. See https://go.dev/s/release
for more details.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I0446af11fc96974ade3c424c486f0738d12c5be8
Gerrit-Change-Number: 800840
Gerrit-PatchSet: 1
Gerrit-Owner: rui xi <ruixir...@gmail.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Comment-Date: Wed, 15 Jul 2026 08:50:00 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
unsatisfied_requirement
satisfied_requirement
open
diffy

Sean Liao (Gerrit)

unread,
Jul 19, 2026, 10:57:47 AM (2 days ago) Jul 19
to rui xi, goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com
Attention needed from rui xi

Sean Liao added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Sean Liao . unresolved

I don't think we should be adding another special case,
rather https://github.com/golang/go/issues/75960 should be fixed and all builtin tools including dist should be listed.

Open in Gerrit

Related details

Attention is currently required from:
  • rui xi
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I0446af11fc96974ade3c424c486f0738d12c5be8
    Gerrit-Change-Number: 800840
    Gerrit-PatchSet: 1
    Gerrit-Owner: rui xi <ruixir...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Sean Liao <se...@liao.dev>
    Gerrit-Attention: rui xi <ruixir...@gmail.com>
    Gerrit-Comment-Date: Sun, 19 Jul 2026 14:57:40 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    rui xi (Gerrit)

    unread,
    Jul 19, 2026, 9:42:46 PM (2 days ago) Jul 19
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from rui xi

    rui xi uploaded new patchset

    rui xi uploaded patch set #2 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • rui xi
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I0446af11fc96974ade3c424c486f0738d12c5be8
    Gerrit-Change-Number: 800840
    Gerrit-PatchSet: 2
    unsatisfied_requirement
    open
    diffy

    rui xi (Gerrit)

    unread,
    Jul 19, 2026, 9:54:17 PM (2 days ago) Jul 19
    to goph...@pubsubhelper.golang.org, Prince Roshan, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Prince Roshan and Sean Liao

    rui xi added 1 comment

    Patchset-level comments

    I don't think we should be adding another special case,
    rather https://github.com/golang/go/issues/75960 should be fixed and all builtin tools including dist should be listed.

    rui xi

    Done. Replaced the one-off dist special case with a general
    approach: enumerate $GOROOT/src/cmd/ and merge missing
    builtin tools using loadBuiltinTool. loadBuiltinTool now also
    verifies package main (via go/parser, excluding \_test.go) so
    that non-tool packages like cmd/tools and cmd/api are
    properly excluded. This fixes #75960 for all tools stripped
    by distpack.

    This aligns with Michael Matloob's feedback on CL 714560,
    where he suggested that loadBuiltinTool itself should
    properly return "" for non-tools.

    This is my first contribution to Go, so I'd really appreciate
    any additional feedback. I'll keep an eye on this CL and
    respond promptly. Thanks!

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Prince Roshan
    • Sean Liao
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I0446af11fc96974ade3c424c486f0738d12c5be8
      Gerrit-Change-Number: 800840
      Gerrit-PatchSet: 2
      Gerrit-Owner: rui xi <ruixir...@gmail.com>
      Gerrit-Reviewer: Prince Roshan <princekr...@gmail.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: Sean Liao <se...@liao.dev>
      Gerrit-Attention: Sean Liao <se...@liao.dev>
      Gerrit-Attention: Prince Roshan <princekr...@gmail.com>
      Gerrit-Comment-Date: Mon, 20 Jul 2026 01:54:07 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Sean Liao <se...@liao.dev>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      rui xi (Gerrit)

      unread,
      Jul 20, 2026, 1:52:41 AM (yesterday) Jul 20
      to goph...@pubsubhelper.golang.org, Prince Roshan, Michael Matloob, Michael Matloob, Gopher Robot, golang-co...@googlegroups.com
      Attention needed from Michael Matloob, Michael Matloob, Prince Roshan and Sean Liao

      rui xi added 1 comment

      File src/cmd/go/internal/tool/tool.go
      Line 206, Patchset 2 (Latest): fmt.Println(name)
      rui xi . unresolved

      This is the result of the program execution.

      go/bin fix-tool-dist [?↑1] #just shell prompt
      ❯ ./go tool
      addr2line
      asm
      buildid
      cgo
      compile
      covdata
      cover
      dist
      distpack
      fix
      link
      nm
      objdump
      pack
      pprof
      preprofile
      test2json
      trace
      vet

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Matloob
      • Michael Matloob
      • Prince Roshan
      • Sean Liao
      Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I0446af11fc96974ade3c424c486f0738d12c5be8
        Gerrit-Change-Number: 800840
        Gerrit-PatchSet: 2
        Gerrit-Owner: rui xi <ruixir...@gmail.com>
        Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
        Gerrit-Reviewer: Michael Matloob <mat...@google.com>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Prince Roshan <princekr...@gmail.com>
        Gerrit-CC: Sean Liao <se...@liao.dev>
        Gerrit-Attention: Michael Matloob <mat...@golang.org>
        Gerrit-Attention: Sean Liao <se...@liao.dev>
        Gerrit-Attention: Michael Matloob <mat...@google.com>
        Gerrit-Attention: Prince Roshan <princekr...@gmail.com>
        Gerrit-Comment-Date: Mon, 20 Jul 2026 05:52:31 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        unsatisfied_requirement
        open
        diffy

        rui xi (Gerrit)

        unread,
        Jul 20, 2026, 1:54:06 AM (yesterday) Jul 20
        to goph...@pubsubhelper.golang.org, Prince Roshan, Michael Matloob, Michael Matloob, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Michael Matloob, Michael Matloob, Prince Roshan and Sean Liao

        rui xi added 1 comment

        File src/cmd/go/internal/tool/tool.go
        rui xi . resolved

        This is the result of the program execution.

        go/bin fix-tool-dist [?↑1] #just shell prompt
        ❯ ./go tool
        addr2line
        asm
        buildid
        cgo
        compile
        covdata
        cover
        dist
        distpack
        fix
        link
        nm
        objdump
        pack
        pprof
        preprofile
        test2json
        trace
        vet

        rui xi

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Michael Matloob
        • Michael Matloob
        • Prince Roshan
        • Sean Liao
        Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          • requirement is not satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I0446af11fc96974ade3c424c486f0738d12c5be8
          Gerrit-Change-Number: 800840
          Gerrit-PatchSet: 2
          Gerrit-Owner: rui xi <ruixir...@gmail.com>
          Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
          Gerrit-Reviewer: Michael Matloob <mat...@google.com>
          Gerrit-CC: Gopher Robot <go...@golang.org>
          Gerrit-CC: Prince Roshan <princekr...@gmail.com>
          Gerrit-CC: Sean Liao <se...@liao.dev>
          Gerrit-Attention: Michael Matloob <mat...@golang.org>
          Gerrit-Attention: Sean Liao <se...@liao.dev>
          Gerrit-Attention: Michael Matloob <mat...@google.com>
          Gerrit-Attention: Prince Roshan <princekr...@gmail.com>
          Gerrit-Comment-Date: Mon, 20 Jul 2026 05:53:58 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: rui xi <ruixir...@gmail.com>
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          rui xi (Gerrit)

          unread,
          Jul 20, 2026, 2:35:02 AM (yesterday) Jul 20
          to goph...@pubsubhelper.golang.org, Russ Cox, Prince Roshan, Michael Matloob, Michael Matloob, Gopher Robot, golang-co...@googlegroups.com
          Attention needed from Michael Matloob, Michael Matloob, Prince Roshan, Russ Cox and Sean Liao

          rui xi voted Code-Review+1

          Code-Review+1
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Michael Matloob
          • Michael Matloob
          • Prince Roshan
          • Russ Cox
          • Sean Liao
          Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          • requirement is not satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I0446af11fc96974ade3c424c486f0738d12c5be8
          Gerrit-Change-Number: 800840
          Gerrit-PatchSet: 2
          Gerrit-Owner: rui xi <ruixir...@gmail.com>
          Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
          Gerrit-Reviewer: Michael Matloob <mat...@google.com>
          Gerrit-Reviewer: Russ Cox <r...@golang.org>
          Gerrit-Reviewer: rui xi <ruixir...@gmail.com>
          Gerrit-CC: Gopher Robot <go...@golang.org>
          Gerrit-CC: Prince Roshan <princekr...@gmail.com>
          Gerrit-CC: Sean Liao <se...@liao.dev>
          Gerrit-Attention: Russ Cox <r...@golang.org>
          Gerrit-Attention: Michael Matloob <mat...@golang.org>
          Gerrit-Attention: Sean Liao <se...@liao.dev>
          Gerrit-Attention: Michael Matloob <mat...@google.com>
          Gerrit-Attention: Prince Roshan <princekr...@gmail.com>
          Gerrit-Comment-Date: Mon, 20 Jul 2026 06:34:52 +0000
          Gerrit-HasComments: No
          Gerrit-Has-Labels: Yes
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          rui xi (Gerrit)

          unread,
          Jul 20, 2026, 2:37:00 AM (yesterday) Jul 20
          to goph...@pubsubhelper.golang.org, Russ Cox, Prince Roshan, Michael Matloob, Michael Matloob, Gopher Robot, golang-co...@googlegroups.com
          Attention needed from Michael Matloob, Michael Matloob, Prince Roshan, Russ Cox and Sean Liao

          rui xi voted Code-Review+0

          Code-Review+0
          Gerrit-Comment-Date: Mon, 20 Jul 2026 06:36:51 +0000
          Gerrit-HasComments: No
          Gerrit-Has-Labels: Yes
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Sean Liao (Gerrit)

          unread,
          Jul 20, 2026, 12:36:19 PM (yesterday) Jul 20
          to rui xi, goph...@pubsubhelper.golang.org, Russ Cox, Prince Roshan, Michael Matloob, Michael Matloob, Gopher Robot, golang-co...@googlegroups.com
          Attention needed from Michael Matloob, Michael Matloob, Prince Roshan, Russ Cox and rui xi

          Sean Liao added 1 comment

          Patchset-level comments
          File-level comment, Patchset 2 (Latest):
          Sean Liao . resolved

          probably should have a test as well

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Michael Matloob
          • Michael Matloob
          • Prince Roshan
          • Russ Cox
          • rui xi
          Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedReview-Enforcement
          • requirement is not satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I0446af11fc96974ade3c424c486f0738d12c5be8
          Gerrit-Change-Number: 800840
          Gerrit-PatchSet: 2
          Gerrit-Owner: rui xi <ruixir...@gmail.com>
          Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
          Gerrit-Reviewer: Michael Matloob <mat...@google.com>
          Gerrit-Reviewer: Russ Cox <r...@golang.org>
          Gerrit-Reviewer: rui xi <ruixir...@gmail.com>
          Gerrit-CC: Gopher Robot <go...@golang.org>
          Gerrit-CC: Prince Roshan <princekr...@gmail.com>
          Gerrit-CC: Sean Liao <se...@liao.dev>
          Gerrit-Attention: Russ Cox <r...@golang.org>
          Gerrit-Attention: Michael Matloob <mat...@golang.org>
          Gerrit-Attention: rui xi <ruixir...@gmail.com>
          Gerrit-Attention: Michael Matloob <mat...@google.com>
          Gerrit-Attention: Prince Roshan <princekr...@gmail.com>
          Gerrit-Comment-Date: Mon, 20 Jul 2026 16:36:09 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Sean Liao (Gerrit)

          unread,
          Jul 20, 2026, 4:13:11 PM (yesterday) Jul 20
          to rui xi, goph...@pubsubhelper.golang.org, Russ Cox, Prince Roshan, Michael Matloob, Michael Matloob, Gopher Robot, golang-co...@googlegroups.com
          Attention needed from Michael Matloob, Michael Matloob, Prince Roshan, Russ Cox and rui xi

          Sean Liao voted Commit-Queue+1

          Commit-Queue+1
          Gerrit-Reviewer: Sean Liao <se...@liao.dev>
          Gerrit-Reviewer: rui xi <ruixir...@gmail.com>
          Gerrit-CC: Gopher Robot <go...@golang.org>
          Gerrit-CC: Prince Roshan <princekr...@gmail.com>
          Gerrit-Attention: Russ Cox <r...@golang.org>
          Gerrit-Attention: Michael Matloob <mat...@golang.org>
          Gerrit-Attention: rui xi <ruixir...@gmail.com>
          Gerrit-Attention: Michael Matloob <mat...@google.com>
          Gerrit-Attention: Prince Roshan <princekr...@gmail.com>
          Gerrit-Comment-Date: Mon, 20 Jul 2026 20:13:02 +0000
          Gerrit-HasComments: No
          Gerrit-Has-Labels: Yes
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          rui xi (Gerrit)

          unread,
          8:54 PM (2 hours ago) 8:54 PM
          to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Russ Cox, Prince Roshan, Michael Matloob, Michael Matloob, Gopher Robot, golang-co...@googlegroups.com
          Attention needed from Michael Matloob, Michael Matloob, Prince Roshan, Russ Cox and Sean Liao

          rui xi added 1 comment

          Patchset-level comments
          Sean Liao . resolved

          probably should have a test as well

          rui xi

          All tests passed. PTAL when you have a chance.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Michael Matloob
          • Michael Matloob
          • Prince Roshan
          • Russ Cox
          • Sean Liao
          Submit Requirements:
            • requirement is not satisfiedCode-Review
            • requirement satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            • requirement satisfiedTryBots-Pass
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I0446af11fc96974ade3c424c486f0738d12c5be8
            Gerrit-Change-Number: 800840
            Gerrit-PatchSet: 2
            Gerrit-Owner: rui xi <ruixir...@gmail.com>
            Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
            Gerrit-Reviewer: Michael Matloob <mat...@google.com>
            Gerrit-Reviewer: Russ Cox <r...@golang.org>
            Gerrit-Reviewer: Sean Liao <se...@liao.dev>
            Gerrit-Reviewer: rui xi <ruixir...@gmail.com>
            Gerrit-CC: Gopher Robot <go...@golang.org>
            Gerrit-CC: Prince Roshan <princekr...@gmail.com>
            Gerrit-Attention: Russ Cox <r...@golang.org>
            Gerrit-Attention: Michael Matloob <mat...@golang.org>
            Gerrit-Attention: Sean Liao <se...@liao.dev>
            Gerrit-Attention: Michael Matloob <mat...@google.com>
            Gerrit-Attention: Prince Roshan <princekr...@gmail.com>
            Gerrit-Comment-Date: Wed, 22 Jul 2026 00:53:54 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Sean Liao <se...@liao.dev>
            unsatisfied_requirement
            satisfied_requirement
            open
            diffy
            Reply all
            Reply to author
            Forward
            0 new messages