Golang交叉编译 作者:Admin Go 时间:2021-11-09 17:07:20 578人已阅读 个人博客 简介交叉编译 ### 交叉编译 GOARCH 目标平台(编译后的目标平台)的处理器架构(386、amd64、arm) GOOS 目标平台(编译后的目标平台)的操作系统(darwin、freebsd、linux、windows) (一)Windows 下编译Linux 64位可执行程序: ``` SET CGO_ENABLED=0 //不设置也可以,原因不明 SET GOOS=linux SET GOARCH=amd64 通过 go env 查看设置是否成功。 ``` (二)Linux 下编译Windows可执行程序: ``` export CGO_ENABLED=0 export GOOS=windows export GOARCH=amd64 通过 go env 查看设置是否成功。 go build hello.go ``` 上一篇: Mysql 获取分组最大的两条数据 下一篇: 二进制搭建PHP