go: cmd/go: go list -e should list a package containing an error if files named on the command line do not exist

$ go version
go version devel +47fb1fbd55 Fri Dec 14 16:18:51 2018 +0000 linux/amd64
$ cd go/src/golang.org/x/tools
$ git show HEAD --no-patch
commit 3c39ce7b61056afe4473b651789da5f89d4aeb20 (HEAD -> master, origin/master, origin/HEAD)
Author: Brad Fitzpatrick <bradfitz@golang.org>
Date:   Fri Dec 14 14:45:46 2018 +0000

    tip: fix, update tip.golang.org
[...]
$ go install ./go/packages/gopackages
$ gopackages missing.go; echo $?
gopackages: go [list -e -json -compiled -test=false -export=false -deps=true -- missing.go]: exit status 1: stat missing.go: no such file or directory
1
$ gopackages -mode syntax missing.go; echo $?
0

Seems to me like the LoadSyntax mode should error too. Found while porting https://github.com/mvdan/gogrep from go/loader to go/packages, since some error test cases stopped erroring as expected.

/cc @ianthehat @matloob

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@mvdan I retitled the issue, sorry about that! @dominikh Hmm… let me look into that…

The underlying problem is that go list -e doesn’t exit 0 (as it should) when an ad-hoc package doesn’t exist. I’ve sent a cl to suppress the error in go packages, and then I’ll re-purpose this bug to target that issue.