Skip to content

cmd/go: confusing error message when flags come before package paths #56310

Open
@josharian

Description

@josharian
-- go.mod --
module m

go 1.19
-- x/t_test.go --
package x

// some test code that has a -foo flag

(Warning: hand-written, untested txtar.)

$ go test ./x -foo
<OK>
$ go test -foo ./x
no Go files in /current/pwd

This is a confusing error message. I think(?) the Go tool has interpreted -foo as a package path, but the error message doesn't reflect that. It's true that there are no Go files in the root, but that's not the problem.

Maybe the Go command could make these two equivalent. But even if it can't, a more useful error message would be welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Unfortunate

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions