簡體   English   中英

`go build -ldflags` 的參數中的 `-X` 是什么意思?

[英]What is the meaning of `-X` in `go build -ldflags`'s arguments?

在 golang 的文檔中,我找不到關於-ldflags參數的任何解釋。

go build -ldflags "-X main.version=${IDE_DATE}-${IDE_VERSION}-${IDE_OS}-${IDE_ARCH}-DEBUG" -o $2 cmd/backend.go

我在哪里可以找到關於-ldflags的文檔?

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.

命令鏈接

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM