Install upx+ compression Golang executable under CentOS

Source: Internet
Author: User
Tags etcd
This is a created article in which the information may have evolved or changed.

CentOS Installation 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.rpmrpm -Uvh ucl-1.03-2.el7.rf.x86_64.rpmyum install uclwget -c http://ftp.tu-chemnitz.de/pub/linux/dag/redhat/el7/en/x86_64/rpmforge/RPMS/upx-3.91-1.el7.rf.x86_64.rpmrpm -Uvh upx-3.91-1.el7.rf.x86_64.rpmyum install upx

#upx压缩golang可执行文件

First add the Compile parameter-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

Can be found in the small nearly 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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.