Commit 529ea7c0 authored by Mark Rushakoff's avatar Mark Rushakoff Committed by Emmanuel Odeke

cmd/go: don't panic when go run is passed ... under nonexistent dir

Given a nonexistent directory above a wildcard:

    go run ./nonexistent/...

Print this error instead of panicking:

    go run: no packages loaded from ./nonexistent/...

Fixes #28696.

Change-Id: Iaa3bc5c78b14ef858d931778e1bc55ca626c5571
GitHub-Last-Rev: bb1a80483ad26c8cf646cf0900d08cfe49aba535
GitHub-Pull-Request: golang/go#28703
Reviewed-on: https://go-review.googlesource.com/c/148821
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
Reviewed-by: 's avatarEmmanuel Odeke <emm.odeke@gmail.com>
parent c92e73b7
......@@ -78,6 +78,9 @@ func runRun(cmd *base.Command, args []string) {
p = load.GoFilesPackage(files)
} else if len(args) > 0 && !strings.HasPrefix(args[0], "-") {
pkgs := load.PackagesAndErrors(args[:1])
if len(pkgs) == 0 {
base.Fatalf("go run: no packages loaded from %s", args[0])
}
if len(pkgs) > 1 {
var names []string
for _, p := range pkgs {
......
# Fix for https://github.com/golang/go/issues/28696:
# go run x/... should not panic when directory x doesn't exist.
! go run nonexistent/...
stderr '^go run: no packages loaded from nonexistent/...$'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment