golang/go

cmd/run: error hint for "no required module provides package" is not helpful

Open

#60,944 建立於 2023年6月22日

在 GitHub 查看
 (5 留言) (1 反應) (0 負責人)Go (19,008 fork)batch import
GoCommandNeedsFixhelp wanted

倉庫指標

Star
 (133,883 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

In a directory that contains a go.mod, use go run to run a package that is not in the dependency graph with no version specified. Currently we tell you to go get tool. This probably isn't what you want (it will temporarily add the tool to your module, but it will be removed on the next go mod tidy). We should consider removing this hint.

$ go run golang.org/x/tools/cmd/stringer
no required module provides package golang.org/x/tools/cmd/stringer; to add it:
	go get golang.org/x/tools/cmd/stringer

I created this issue to track the work mentioned on this comment from @rsc on https://github.com/golang/go/issues/48429#issuecomment-1601062050

@ConradIrwin, I think that error message change is not correct. If people are using "go run" then we shouldn't tell them to do something that is meant to be used with "go tool" but accidentally also makes "go run" work. Honestly I think the "to add it" note should probably be removed entirely. There are two possible ways to fix that error. The other is to add @version to the command line. Often that's what you want instead. We should stop presuming one solution.

貢獻者指南