CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了centos下安装UPX+压缩golang可执行程序大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

centos安装upx wget -c http://ftp.tu-chemnitz.de/pub/linux/dag/redhat/el7/en/x86_64/rpmforge/RPMS/ucl-1.03-2.el7.rf.x86_64.rpm rpm -Uvh ucl-1.03-2.el7.rf.x86_64.rpm yum install ucl wget -c http://ftp.tu

centos安装upx

wget -c http://ftp.tu-chemnitz.de/pub/linux/dag/redhat/el7/en/x86_64/rpmforge/RPMS/ucl-1.03-2.el7.rf.x86_64.rpm
rpm -Uvh ucl-1.03-2.el7.rf.x86_64.rpm
yum install ucl

wget -c http://ftp.tu-chemnitz.de/pub/linux/dag/redhat/el7/en/x86_64/rpmforge/RPMS/upx-3.91-1.el7.rf.x86_64.rpm
rpm -Uvh upx-3.91-1.el7.rf.x86_64.rpm
yum install upx

#upx压缩golang可执行文件

首先加上编译参数-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

可以发现小了近1MB

$ 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

大佬总结

以上是大佬教程为你收集整理的centos下安装UPX+压缩golang可执行程序全部内容,希望文章能够帮你解决centos下安装UPX+压缩golang可执行程序所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。