压缩可执行文件
首先加上编译参数-ldflags

$ go build -ldflags '-w -s'
$ ls -lh
-rwxr-xr-x  1 gangan  staff   2.5M Aug 18 00:45 etcd-cli
-rw-r--r--  1 gangan  staff   456B Aug 18 00:34 main.go

使用upx压缩,Linux、Mac和Win都有,这里以Mac为例

$ brew install upx
$ upx etcd-cli
# 此处省略压缩时的打印...
$ ls -lh
-rwxr-xr-x  1 gangan  staff   897K Aug 18 00:49 etcd-cli
-rw-r--r--  1 gangan  staff   456B Aug 18 00:34 main.go

相关文章:

  • 2022-12-23
  • 2022-01-18
  • 2021-09-01
  • 2021-09-10
  • 2021-12-02
  • 2021-11-17
猜你喜欢
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2021-09-14
  • 2021-10-20
  • 2021-03-31
  • 2021-12-13
相关资源
相似解决方案