Skip to content

Instantly share code, notes, and snippets.

@jacob-faber
Last active July 25, 2020 18:29
Show Gist options
  • Save jacob-faber/a02e6846e00251e1820c784516c0318f to your computer and use it in GitHub Desktop.
Save jacob-faber/a02e6846e00251e1820c784516c0318f to your computer and use it in GitHub Desktop.
Golang build flags
// Go 1.6.1, Some combinations are valid, some not
// The known operating systems.
var okgoos = []string{
"darwin",
"dragonfly",
"linux",
"android",
"solaris",
"freebsd",
"nacl",
"netbsd",
"openbsd",
"plan9",
"windows",
}
// The known architectures.
var okgoarch = []string{
"386",
"amd64",
"amd64p32",
"arm",
"arm64",
"mips64",
"mips64le",
"ppc64",
"ppc64le",
"s390x",
}
// Valid combinations
var cgoEnabled = map[string]bool{
"darwin/386": true,
"darwin/amd64": true,
"darwin/arm": true,
"darwin/arm64": true,
"dragonfly/amd64": true,
"freebsd/386": true,
"freebsd/amd64": true,
"freebsd/arm": true,
"linux/386": true,
"linux/amd64": true,
"linux/arm": true,
"linux/arm64": true,
"linux/ppc64le": true,
"android/386": true,
"android/amd64": true,
"android/arm": true,
"netbsd/386": true,
"netbsd/amd64": true,
"netbsd/arm": true,
"openbsd/386": true,
"openbsd/amd64": true,
"solaris/amd64": true,
"windows/386": true,
"windows/amd64": true,
"linux/s390x": true,
}
$ GOOS=<okgoos> GOARCH=<okgoarch> go build ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment