-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
GoCommandcmd/gocmd/goNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
(I'm on go version go1.19.5 linux/amd64)
go test reports a warning if there's nothing to do:
$ go test -run test_that_doesn't_exist
testing: warning: no tests to run
The commands go test, go run, go build, and go install will also warn if there are no Go files in the given directory.
$ go test
no Go files in /directory
(In the case of go run, the warning is go: no go files listed)
However, unlike go test and go run, go build and go 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:
package hello
import "fmt"
func talk() {
fmt.Println("Hello World!")
}
go run warns
$ go run helloWorld.go
package command-line-arguments is not a main package
go test warns
$ go test
? /helloWorldDir [no test files]
$ go test helloWorld.go
? command-line-arguments [no test files]
But go install and go build reports nothing.
$ go install helloWorld.go
$
$ go build helloWorld.go
$
And simply doing go install and go build also reports nothing.
$ go install
$
$ go build
$
What I would expect to see is the same warning as go run
$ go install
package is not a main package
$ go build
package is not a main package
Metadata
Metadata
Assignees
Labels
GoCommandcmd/gocmd/goNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.