我目前正在参加一个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

Go相关问答推荐

如何在Go中使用a-h/tempson渲染预格式的内容?

Golang socks 5代理,流量限制转发到下一个socks 5代理

消费者在NAT中是如何实现的

Kafka消费者在需要时不会暂停

困扰围棋官方巡回赛的S建议所有方法都使用同一类型的接收器

如何使用Gorilla WebSockets实现Http.Hijacker&;alexedwards/scs/v2

如何使用 GolangCI 删除未使用的导入

判断一个区域内的纬度/经度点

Go 的垃圾收集器在使用时删除 ZeroMQ 套接字

不能使用 mockDB(*MockDB 类型的变量)作为 struct 文字中的 *gorm.DB 值

接受通道和切片的通用函数

数据流中的无根单元错误,从 Golang 中的 PubSub 到 Bigquery

使用 package`regexp` 查找 Golang 中的所有 mactch 子字符串,但得到意外结果

使用 Golang SQL 驱动程序连接到snowflake

如何在gin中获取参数值数组

使用 oklog/run 来自 Go 编译器的错误(无值)用作值

GRPC 反向代理混淆 GRPC 和 GRPC-Web

从 map 返回空数组而不是空字符串数组

如何从应用程序调用谷歌云身份 API

Go 1.18 泛型如何使用接口定义新的类型参数