From 8529d99e1d447e930a1172e5f30fe6c1f46922e6 Mon Sep 17 00:00:00 2001 From: ChaiShushan Date: Fri, 12 Jul 2013 09:41:10 +1000 Subject: [PATCH] misc/goplay: use `go run x.go` instead of `go build x.go` when the program is not main package, `go run x.go` can't return the link error message. so use `go run x.go` in instead `go build x.go`. Fixes #5865. R=golang-dev, adg CC=golang-dev https://golang.org/cl/11165043 --- misc/goplay/goplay.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/misc/goplay/goplay.go b/misc/goplay/goplay.go index 94d04139dd6..9cb7d7bfb8a 100644 --- a/misc/goplay/goplay.go +++ b/misc/goplay/goplay.go @@ -14,7 +14,6 @@ import ( "os/exec" "path/filepath" "regexp" - "runtime" "strconv" "text/template" ) @@ -92,10 +91,6 @@ func compile(req *http.Request) (out []byte, err error) { // x is the base name for .go, .6, executable files x := filepath.Join(tmpdir, "compile"+strconv.Itoa(<-uniq)) src := x + ".go" - bin := x - if runtime.GOOS == "windows" { - bin += ".exe" - } // rewrite filename in error output defer func() { @@ -116,16 +111,13 @@ func compile(req *http.Request) (out []byte, err error) { return } - // build x.go, creating x + // go run x.go dir, file := filepath.Split(src) - out, err = run(dir, "go", "build", "-o", bin, file) - defer os.Remove(bin) + out, err = run(dir, "go", "run", file) if err != nil { return } - - // run x - return run("", bin) + return out, nil } // error writes compile, link, or runtime errors to the HTTP connection.