我目前正在學習微服務在線課程,我將小型 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 關注
- 548 瀏覽
添加回答
舉報
0/150
提交
取消
