This is a creation in Article, where the information may have evolved or changed. go Build-ldflags "-s-w" (go install similar)
explain the meaning of the parameter:
-ldflags: Indicates that the following parameters are passed to the connector (5/6/8l)
- S: Remove the symbol information (and then panic when the stack trace does not have any file name/line number information, which is equivalent to the general C/s program is strip effect)
-W: Removes dwarf debug information. The resulting program cannot be debugged with GDB.
The following Demo.go
[AppleScript] Plain Text View Copy Code
| 12345 |
package main import (" FMT ") func main () {      fmt. Print (" hellow! ") } |
E:\go Build Demo.go//compiled for 1163 K
E:\go build-ldflags "-s-w" demo.go//compiled for 591K
-S and-W can also be used separately, generally if you do not intend to debug with GDB,-W basically no loss.
the loss of-S is a bit big.