在 Mac、Linux、Windows 下Go交叉编译

Go语言支持交叉编译,在一个平台上生成另一个平台的可执行程序,最近使用了一下,非常好用,这里备忘一下。

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

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

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

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

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

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

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

 跨平台交叉编译

 

相关文章:

  • 2021-07-06
  • 2022-12-23
  • 2021-06-05
  • 2021-05-29
  • 2021-06-22
  • 2022-01-31
  • 2021-05-31
猜你喜欢
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案