1
0
mirror of https://github.com/golang/go synced 2024-11-21 23:44:39 -07:00

cmd/go: fix run errors

$ go run
go run: no go files listed
$ go run ../../pkg/math/bits.go
go run: cannot run non-main package
$

Fixes #3168.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5755064
This commit is contained in:
Russ Cox 2012-03-07 00:01:57 -05:00
parent 47ee98253e
commit 85ae6a18b5

View File

@ -42,12 +42,15 @@ func runRun(cmd *Command, args []string) {
i++
}
files, cmdArgs := args[:i], args[i:]
if len(files) == 0 {
fatalf("go run: no go files listed")
}
p := goFilesPackage(files)
if p.Error != nil {
fatalf("%s", p.Error)
}
if p.Name != "main" {
fatalf("cannot run non-main package")
fatalf("go run: cannot run non-main package")
}
p.target = "" // must build - not up to date
a1 := b.action(modeBuild, modeBuild, p)