在windows下将go程序打包为linux可执行程序

  1. 打开文件所在目录,在资源路径框中输入cmd,打开cmd命令框(不要直接在goland或其他编程软件中进行)
  2. 配置编译环境参数如下所示
set GOOS=linux
set GOARCH=amd64

3.编译打包命令

go build main.go
  1. 上传到linux系统
  2. chmod +x main.添加可执行权限

猜你喜欢

转载自blog.csdn.net/qq_45808700/article/details/131419641