Categories
go

go cmd

go build

go build main.go xxxx xxx -o main

go 交叉编译

mac下

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build filename.go

# Windows

CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build filename.go

linux 下

# Mac

CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build filename.go # Windows

CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build filename.go

windows下

# Mac

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

# Linux

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

Leave a Reply