![](/img/trans.png)
[英]What is the meaning of `-static` in `go build -ldflags`'s arguments?
[英]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.