[go] cmd/go: validate module paths in go mod why -m

0 views
Skip to first unread message

Sean Liao (Gerrit)

unread,
Aug 10, 2026, 12:50:25 PM (17 hours ago) Aug 10
to shuang cui, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Dmitri Shuralyov, Damien Neil, Mark Freeman, Carlos Amedee, Dmitri Shuralyov, Michael Matloob, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com

Sean Liao submitted the change

Change information

Commit message:
cmd/go: validate module paths in go mod why -m

Validate non-pattern module arguments before loading the module graph.
Report malformed paths on stderr and exit with a non-zero status.

Use module.CheckImportPath instead of module.CheckPath so paths permitted
through replace directives, such as mymodule/nested, remain accepted.

Add regression tests for a module path with a trailing slash and for a
replacement-only module path.

Fixes #36658
Change-Id: I17ba59ae0655fab78e3a715514e75479d4f45ba8
Reviewed-by: Sean Liao <se...@liao.dev>
Reviewed-by: Mark Freeman <markf...@google.com>
Reviewed-by: Dmitri Shuralyov <dmit...@google.com>
Files:
  • M src/cmd/go/internal/modcmd/why.go
  • M src/cmd/go/testdata/script/mod_why.txt
Change size: M
Delta: 2 files changed, 63 insertions(+), 0 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I17ba59ae0655fab78e3a715514e75479d4f45ba8
Gerrit-Change-Number: 802480
Gerrit-PatchSet: 3
Gerrit-Owner: shuang cui <imc...@gmail.com>
Gerrit-Reviewer: Carlos Amedee <car...@golang.org>
Gerrit-Reviewer: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@golang.org>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@google.com>
Gerrit-Reviewer: Mark Freeman <markf...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-Reviewer: Sean Liao <se...@liao.dev>
Gerrit-Reviewer: shuang cui <imc...@gmail.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages