mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
fix small error in -X usage
parent
1076d849f2
commit
f7b9c51f61
@ -104,6 +104,6 @@ package buildinfo
|
||||
var BuildTime string
|
||||
```
|
||||
|
||||
You can build the program using this package using `go build -ldflags="-X 'company/buildinfo=$(date)'"` to record the build time in the string. (The use of `$(date)` assumes you are using a Unix-style shell.)
|
||||
You can build the program using this package using `go build -ldflags="-X 'company/buildinfo.BuildTime=$(date)'"` to record the build time in the string. (The use of `$(date)` assumes you are using a Unix-style shell.)
|
||||
|
||||
The string variable must exist, and it must be a variable, not a constant. There is no warning for using the wrong name in the `-X` option. You can often find the name to use by running `go tool nm` on the program, but that will fail if the package name has any non-ASCII characters, or a `"` or `%` character.
|
Loading…
x
Reference in New Issue
Block a user