Skip to content

Commit 6891c0f

Browse files
cmd/go: don't panic when go run is passed ... under nonexistent dir
Fixes #28696.
1 parent c5aea7a commit 6891c0f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/cmd/go/internal/run/run.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ func runRun(cmd *base.Command, args []string) {
7878
p = load.GoFilesPackage(files)
7979
} else if len(args) > 0 && !strings.HasPrefix(args[0], "-") {
8080
pkgs := load.PackagesAndErrors(args[:1])
81+
if len(pkgs) == 0 {
82+
base.Fatalf("go run: no package to run", args[0])
83+
}
8184
if len(pkgs) > 1 {
8285
var names []string
8386
for _, p := range pkgs {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Fix for https://github.com/golang/go/issues/28696:
2+
# go run x/... should not panic when directory x doesn't exist.
3+
4+
! go run x/...
5+
stderr '^go run: no package to run'

0 commit comments

Comments
 (0)