为了账号安全,请及时绑定邮箱和手机立即绑定

`go build -ldflags` 参数中的 `-X` 是什么意思?

`go build -ldflags` 参数中的 `-X` 是什么意思?

Go
米琪卡哇伊 2023-08-07 19:03:36
在golang的文档中,我找不到任何关于 的参数的解释-ldflags。go build -ldflags "-X main.version=${IDE_DATE}-${IDE_VERSION}-${IDE_OS}-${IDE_ARCH}-DEBUG" -o $2 cmd/backend.go我在哪里可以找到有关的文档-ldflags?
查看完整描述

1 回答

?
慕标琳琳

TA贡献1830条经验 获得超9个赞

ldflags 代表链接器标志,用于将标志传递给底层链接器。根据文档:


-X importpath.name=value

    Set the value of the string variable in importpath named name to value.

    This is only effective if the variable is declared in the source code either uninitialized

    or initialized to a constant string expression. -X will not work if the initializer makes

    a function call or refers to other variables.

    Note that before Go 1.5 this option took two separate arguments.

查看完整回答
反对 回复 2023-08-07
  • 1 回答
  • 0 关注
  • 94 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信