Miaow

Creator of @nest-cloud and @i5sing. Senior Software Engineer at @YanRongTech. Master of JavaScript, TypeScript. ❤️ Open Source <3.

Powered by Meow
Forked from github/personal-website
辽ICP备16013530号

Home

Golang 交叉编译

Published 2019-01-14

Mac 下编译 Linux 和 Windows 64位可执行程序

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go

Linux 下编译 Mac 和 Windows 64位可执行程序

CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go

Windows 下编译 Mac 和 Linux 64位可执行程序

SET CGO_ENABLED=0
SET GOOS=darwin
SET GOARCH=amd64
go build main.go

SET CGO_ENABLED=0
SET GOOS=linux
SET GOARCH=amd64
go build main.go

GOOS #目标平台的操作系统(darwin、freebsd、linux、windows)
GOARCH #目标平台的架构(386、amd64、arm)