aboutsummaryrefslogtreecommitdiff
path: root/test/linkx_run.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-05-21 14:35:02 -0400
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-06-05 04:55:41 +0000
commit12795c02f3d6fc54ece09a86e70aaa40a94d5131 (patch)
treee823ba0f095be8debdd0a4a8440658801e27fab8 /test/linkx_run.go
parent630930c35ef7b5e22e28a6424425b887bb12c9b6 (diff)
downloadgo-12795c02f3d6fc54ece09a86e70aaa40a94d5131.tar.gz
go-12795c02f3d6fc54ece09a86e70aaa40a94d5131.zip
cmd/link: deprecate -X name value in favor of -X name=value
People invoking the linker directly already have to change their scripts to use the new "go tool link", so this is a good time to make the -X flag behave like all other Go flags and take just a single argument. The old syntax will continue to be accepted (it is rewritten into the new syntax before flag parsing). Maybe some day we will be able to retire it. Even if we never retire the old syntax, having the new syntax at least makes the rewriting much less of a kludge. Change-Id: I91e8df94f4c22b2186e81d7f1016b8767d777eac Reviewed-on: https://go-review.googlesource.com/10310 Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'test/linkx_run.go')
-rw-r--r--test/linkx_run.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/test/linkx_run.go b/test/linkx_run.go
index f3029f50a9..cc0f55cf92 100644
--- a/test/linkx_run.go
+++ b/test/linkx_run.go
@@ -10,23 +10,33 @@
package main
import (
+ "bytes"
"fmt"
"os"
"os/exec"
)
func main() {
+ test(" ") // old deprecated syntax
+ test("=") // new syntax
+}
+
+func test(sep string) {
// Successful run
- cmd := exec.Command("go", "run", "-ldflags=-X main.tbd hello -X main.overwrite trumped -X main.nosuchsymbol neverseen", "linkx.go")
- out, err := cmd.CombinedOutput()
+ cmd := exec.Command("go", "run", "-ldflags=-X main.tbd"+sep+"hello -X main.overwrite"+sep+"trumped -X main.nosuchsymbol"+sep+"neverseen", "linkx.go")
+ var out, errbuf bytes.Buffer
+ cmd.Stdout = &out
+ cmd.Stderr = &errbuf
+ err := cmd.Run()
if err != nil {
- fmt.Println(string(out))
+ fmt.Println(errbuf.String())
+ fmt.Println(out.String())
fmt.Println(err)
os.Exit(1)
}
want := "hello\ntrumped\n"
- got := string(out)
+ got := out.String()
if got != want {
fmt.Printf("got %q want %q\n", got, want)
os.Exit(1)