]> Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/load: treat packages with errors as potentially main packages
authorBryan C. Mills <bcmills@google.com>
Tue, 27 Apr 2021 07:01:08 +0000 (03:01 -0400)
committerBryan C. Mills <bcmills@google.com>
Tue, 27 Apr 2021 18:34:55 +0000 (18:34 +0000)
commit8e0023b81b81352c1f8ea5cd58eea91939924f9d
tree8dee53704eb0dc0a3fc5999823651ab27e893d11
parentbd2175e1b1369bce59cdceb9282c817802a87746
cmd/go/internal/load: treat packages with errors as potentially main packages

If a package declares 'package main' but for some reason we fail to
read its name (for example, due to a permission or checksum error),
we may be tempted to drop the package from the output of
mainPackagesOnly. However, that leads to a confusing
"no packages loaded from …" error message.

Instead, we will treat packages with errors as potentially-main
packages, and print the error. At least if we print why the package is
broken, the user will understand that the weird behavior is due to the
broken package rather than, say, a typo on their part in the command
arguments.

Updates #42088
For #36460

Change-Id: I033c0d28ac7d105d9df3ba5f9327e5c0c2a29954
Reviewed-on: https://go-review.googlesource.com/c/go/+/314050
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
src/cmd/go/internal/load/pkg.go