If I get it right, GOOS
is determined when compile the source code.
To better support multiple OS, I'm interested in what GOOS
could be.
Of course, there might be infinite possibilities of it, since Go is opensourced. So what I really want is a "common list".
Known values are:
windows
linux
darwin
orfreebsd
orunix
? I know that at least one of them must exist.
I think you're looking for this list of possible GOOS and GOARCH combinations, in this section:
http://golang.org/doc/install/source#environment
Note that those values are defined in
src/go/build/syslist.go
.With Go 1.5 (Q3 2015),
GOARCH
will become much more complete.See commit 1eebb91 by Minux Ma (
minux
)The list is still being review in Change 9644, with comments like:
The official documentation now (GO 1.5+ Q3 2015) reflects that completed list.
Update 2018: as documented in Giorgos Oikonomou's answer, Go 1.7 (Q1 2016) has introduced the
go tool dist list
command.See commit c3ecded: it fixes issue 12270 opened in Q3 2015:
This was implemented in CL 19837
You can list in plain text, or in json:
As Mark Bates tweeted:
You can see the list of supported platform by running:
go tool dist list
and this will print(depending on the Go version):
And the official documentation for the tool:
https://godoc.org/github.com/golang/go/src/cmd/dist
To cross compile use: