golang: impressed by its cross compiling possibilities

GOOS="windows" GOARCH="amd64" go build

However till now golang's debug functionality seems far from okay. During debug you cannot print map objects.

And also from debugging related aspects, tool dlv does not support arm arch.

Using an undefined variable can be assigned from function return, or by define.

// The following defines a,b,c
a, b, _ := func()
var c = 1+2

According to this and by go tool link --help, compile statically using:

CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' .

compiling without debug info using: -ldflags '-s -w'

posted on 2018-07-08 07:48  三叁  阅读(119)  评论(0编辑  收藏  举报

导航