-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: go install
should warn or error if none of its arguments have install targets
#58666
Comments
The fact that the Go command prints nothing when you run "go build helloWorld.go" doesn't mean that nothing's happening, it just means that there was nothing to report at the end of the build action. Try running "go build -x" to see what's happening. In addition, developers run "go build" on non-main packages all the time without any expectation that a binary is going to be produced-- they just want to see if the code still compiles after a change to the source. People also run builds of non-main packages to gather more info. For example in your |
Perhaps |
When using GOPATH mode, CC @bcmills |
go install
and go build
: Commands should warn if no binary is produced.go install
should warn for a non-main package
go install
should warn for a non-main packagego install
should warn for a non-main package in module mode
On the other hand, I think it would make sense for |
go install
should warn for a non-main package in module modego install
should warn or error if none of its arguments have install targets
@bcmills would you recommend this as a good first issue for someone looking to contribute? |
@anthoturc, I'm honestly not sure. 😅 But if you want to take a look, the entry point for the |
(I'm on
go version go1.19.5 linux/amd64
)go test
reports a warning if there's nothing to do:The commands
go test
,go run
,go build
, andgo install
will also warn if there are no Go files in the given directory.(In the case of
go run
, the warning isgo: no go files listed
)However, unlike
go test
andgo run
,go build
andgo install
will not warn when a Go file is present in the current directory but no binary is produced.For example, in a directory with file
helloWorld.go
with the contents of the following:go run
warnsgo test
warnsBut
go install
andgo build
reports nothing.And simply doing
go install
andgo build
also reports nothing.What I would expect to see is the same warning as
go run
The text was updated successfully, but these errors were encountered: