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>
This commit is contained in:
Russ Cox 2015-05-21 14:35:02 -04:00 committed by Gerrit Code Review
parent 630930c35e
commit 12795c02f3
4 changed files with 52 additions and 24 deletions

View file

@ -917,14 +917,12 @@ func strnput(s string, n int) {
}
}
var addstrdata_name string
func addstrdata1(arg string) {
if strings.HasPrefix(arg, "VALUE:") {
addstrdata(addstrdata_name, arg[6:])
} else {
addstrdata_name = arg
i := strings.Index(arg, "=")
if i < 0 {
Exitf("-X flag requires argument of the form importpath.name=value")
}
addstrdata(arg[:i], arg[i+1:])
}
func addstrdata(name string, value string) {