当前位置:网站首页>Packaging and deployment of go projects
Packaging and deployment of go projects
2022-08-02 06:13:00 【m0_67401228】
1.go project is compiled and packaged easily under window
1). Directly compile and generate the main.exe file under windows
Execute the following command in the same level directory of the project main.gogo build main.go
2). Package main.go in the current directory into a gotest.exe file (can be executed directly under windows)
InExecute the following command in the same level directory as project main.gogo build -o gotest.exe main.go
9294afd259b12.png)
2. The project is packaged under the window into a file that can be run by other systems
1).Package it into linux under window
In the same level directory of the project main.go, execute the following commands one by one
set CGO_ENABLED=0set GOOS=linuxset GOARCH=amd64go build -o main-linux main.go
Put the abc-demo-linux file into any folder of the linux system, chmod 773 to give the file executable permission, and execute the ./abc-demo-linux
command in the current folder.The executable file (no need to install go, just a binary file) can be run directly
2). Package it into an executable file under the window.
In the same level directory of the project main.go, execute the following commands one by one
set CGO_ENABLED=0set GOOS=windowsset GOARCH=amd64go build -o main-windows.exe main.go
3). Package it into a mac system executable file under the window.
In the same level directory of the project main.go, execute the following commands one by one
set CGO_ENABLED=0set GOOS=darwinset GOARCH=amd64go build -o main-mac main.go
3. The project is packaged into a file that can be run by other systems under Mac
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o abc-demo-linux main.goCGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o abc-demo-mac main.goCGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o abc-demo-windows.exe main.go
4.Linux host compile Widows,MAC client
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o abc-demo-linux main.goCGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o adc-demo-mac main.goCGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o abc-demo-windows.exe main.go
5. Use goreleaser for multi-platform packaging
1).Install goreleaser
goreleaser download address
Configure environment variables after decompression
After filling in the environment variables, all the way is OK
View version in cmdgoreleaser -v
2). Execute the goreleaser init initialization configuration in the project root directory
Execute the goreleaser init
command in the project root directory, and a .goreleaser.yaml
file
3).Add git support and add tags at the same time
Execute the following command in the project root directory
Use git to associate github
git initgit add .git commit -m "go project"git remote add origin own github addressgit push -u origin master
4).Packaging with goreleaser
Packaging commandgoreleaser --snapshot --skip-publish --rm-dist
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
- 12个MySQL慢查询的原因分析
- go项目的打包部署
- el-input 只能输入整数(包括正数、负数、0)或者只能输入整数(包括正数、负数、0)和小数
- golang's time package: methods for time interval formatting and output of timestamp formats such as seconds, milliseconds, and nanoseconds
- Android Studio 实现登录注册-源代码 (连接MySql数据库)
- 100 latest software testing interview questions in 2022, summary of common interview questions and answers
- leetcode 665. Non-decreasing Array 非递减数列(中等)
- WiFi、蓝牙、zigbee锁与NB、Cat.1锁的区别
- 力扣 2127. 参加会议的最多员工数 拓扑剪枝与2360补充
- 牛客-TOP101-BM41
猜你喜欢
navicat connects to MySQL and reports an error: 1045 - Access denied for user 'root'@'localhost' (using password YES)
mysql 存储过程详解
"Digital reconstruction of the system, getting the CEO is the first step"
apisix-入门使用篇
MySQL 8.0.28 version installation and configuration method graphic tutorial
Android studio连接MySQL并完成简单的登录注册功能
系统(层次)聚类
数学建模学习笔记:层次分析法(AHP)
浏览器的onload事件
interrupt()、interrupted()和isInterrupted()你真的懂了吗
随机推荐
Mysql return table
MySQL安装教程
golang的time包:时间间隔格式化和秒、毫秒、纳秒等时间戳格式输出的方法
Mysql 回表
MySQL 5.7 upgrade to 8.0 detailed process
认识消防报警联网中CAN光纤转换器的光纤接口和配套光纤线缆
MySql字符串拆分实现split功能(字段分割转列、转行)
JUC(二)原子类:CAS、乐观锁、Unsafe和原子类
高防服务器防御的原理是什么
Android studio连接MySQL并完成简单的登录注册功能
swinIR论文阅读笔记
MySQL 5.7详细下载安装配置教程
Navicat报错:1045 -拒绝访问用户[email protected](使用passwordYES)
MySQL导入sql文件的三种方法
2022河南萌新联赛第(四)场:郑州轻工业大学 C - 最大公因数
Matlab学习第二天
interrupt()、interrupted()和isInterrupted()你真的懂了吗
Browser onload event
选择黑盒测试用例设计方法的综合策略方案总结
Matlab paper illustration drawing template No. 41 - bubble chart (bubblechart)