Are Golang binaries portable?

前端 未结 1 1671
萌比男神i
萌比男神i 2020-12-29 19:04

Suppose I\'m a primarily Linux user, but I\'m developing an application in Go that I want to be cross platform. I\'ve searched around, but I can\'t seem to find information

1条回答
  •  有刺的猬
    2020-12-29 19:26

    1. Yes it will; this is true of basically all binaries compiled for 64-bit Linux, not just those written in Go (except for shared libraries, which Go doesn't rely on)
    2. You can set the GOOS and GOARCH environment variables before building: GOOS=windows GOARCH=386 go build (or go install or whatever), etc
    3. By default a binary will be built for the system you're running, but this isn't necessary - see 2

    0 讨论(0)
提交回复
热议问题