go命令行多参数传值

goarg.go

/*
* go run -ldflags "-X main.x a -X main.y b -X main.z c" goarg.go
*/

package main

import (
. "fmt"
)

var (
x, y, z string
)

func main() {
Println(x, y, z)
}

go run

go run -ldflags "-X main.x a -X main.y b -X main.z c" goarg.go

控制台输出

GoSublime r13.12.26-3 9o: type `help` for help and command documentation

[ `go version` | done: 99.6094ms ]
go version go1.2 windows/amd64
[ `go run -ldflags "-X main.x a -X main.y b -X main.z c" goarg.go` | done: 4.6806641s ]
a b c
[ D:/gowork/src/ ] #

参考文章

http://stackoverflow.com/questions/11354518/golang-application-auto-build-versioning