Some Tips for Optimizing Program Builds
· β 3 min read
Continuously updated…
1. Golang Use trimpath to remove the build path, avoiding exposure of build path information 1 go build -gcflags="all=-trimpath=${PWD}" -asmflags="all=-trimpath=${PWD}" -o ./bin/opscli ./cmd/cli/main.go Before adding it, a panic prints the path /Users/shaowenchen/Code/Github/ops/main.go; after adding it, a panic prints main.go.
-ldflags “-w -s” removes debug information and reduces the binary size 1 go build -ldflags "-w -s" -o .