我目前正在学习微服务在线课程,我将小型 Go 应用程序部署到 docker 容器。用于构建二进制文件的长而丑陋的命令行是这样的:go build --tags netgo --ldflags '-extldflags "-lm -lstdc++ -static"'到目前为止,我只是用来go install编译我的 go 应用程序。谁能向我解释这个命令?
1 回答
慕标5832272
TA贡献1966条经验 获得超4个赞
--tags netgo 用于使用 go lang 网络栈
--ldflags设置传递给“go tool link”的标志
args 到 ldflags 的值在go tool 链接帮助中有说明
-extldflags flags
Set space-separated flags to pass to the external linker.
在这种情况下,外部链接器是“ld”,因此您可以阅读它的手册页
每个参数的含义是:
-lm enables linking of the standard math library
-lstdc++ enables linking of the standard c++ library
-static means do not link against shared libraries
- 1 回答
- 0 关注
- 407 浏览
添加回答
举报
0/150
提交
取消