我目前正在参加一个microservice在线课程,我将小型go应用程序部署到docker容器中.构建二进制文件的长而难看的命令行是:
go build --tags netgo --ldflags '-extldflags "-lm -lstdc++ -static"'
到目前为止,我只用了go install
来编译我的围棋应用程序.
谁能给我解释一下这个命令吗?
我目前正在参加一个microservice在线课程,我将小型go应用程序部署到docker容器中.构建二进制文件的长而难看的命令行是:
go build --tags netgo --ldflags '-extldflags "-lm -lstdc++ -static"'
到目前为止,我只用了go install
来编译我的围棋应用程序.
谁能给我解释一下这个命令吗?
--标签netgo is used to use go lang network stack
--ldflags sets the flags that are passed to 'go tool link'
args到ldflags的值在go tool link help中解释
-extldflags flags
Set space-separated flags to pass to the external linker.
In this case the external linker is 'ld'
so you can read the man page for it
Meaning of each of the arguments is:
-lm enables linking of the standard math library
-lstdc++ enables linking of the standard c++ library
-static means do not link against shared libraries