Skip to content

cmd/go: tool should explicitely reject an empty tool name #74757

Closed

Description

@dolmen

Go version

go version go1.24.5 darwin/arm64

Output of go env in your module/workspace:

GOROOT='/opt/homebrew/Cellar/go/1.24.5/libexec'

What did you do?

$ go tool !
go: no such tool "!"
$ go tool ""
go tool : fork/exec /opt/homebrew/Cellar/go/1.24.5/libexec/pkg/tool/darwin_arm64: permission denied

What did you see happen?

The error message shows that the tool execution failure is caught by the OS which was given a directory path instead of a executable file path.

What did you expect to see?

go tool should reject much earlier such an invalid tool name and immediately fail with an error message.

$ go tool ""
go: no such tool ""

Activity

  1. dolmen commented on Jul 25, 2025

    @dolmen
    ContributorAuthor

    The implementation of tool lookup is in cmd/go/internal/base.Tool and ToolPath.

  2. dolmen commented on Jul 25, 2025

    @dolmen
    ContributorAuthor

    Patch in progress...

  3. gopherbot commented on Jul 25, 2025

    @gopherbot
    Contributor

    Change https://go.dev/cl/690435 mentions this issue: cmd/go/internal/base: reject an empty tool name

  4. gabyhelp commented on Jul 25, 2025

    @gabyhelp
  5. added
    ToolProposalIssues describing a requested change to a Go tool or command-line program.
    on Jul 25, 2025
  6. mknyszek commented on Jul 25, 2025

    @mknyszek
    Contributor

    CC @golang/command-line

  7. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Jul 25, 2025
  8. added this to the Backlog milestone on Jul 25, 2025
  9. added
    FixPendingIssues that have a fix which has not yet been reviewed or submitted.
    on Jul 26, 2025
  10. removed
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Mar 19, 2026
  11. modified the milestones: Backlog, Go1.27 on Mar 19, 2026
  12. added a commit that references this issue on Mar 19, 2026
    86b5e67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.GoCommandcmd/goToolProposalIssues describing a requested change to a Go tool or command-line program.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions