This code is taken from dev-lang/go. No other packages have code like this, but some erroneously call `go env GOOS`, which is bad for cross-compiling. They should use this function instead.
Signed-off-by: James Le Cuirot <ch...@gentoo.org> --- eclass/go-env.eclass | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass index c839c41be0d7e..be131133113be 100644 --- a/eclass/go-env.eclass +++ b/eclass/go-env.eclass @@ -48,6 +48,24 @@ go-env_set_compile_environment() { export CGO_LDFLAGS="${CGO_LDFLAGS:-$LDFLAGS}" } +# @FUNCTION: go-env_goos +# @USAGE: [toolchain prefix] +# @DESCRIPTION: +# Returns the appropriate GOOS setting for the target operating system. +go-env_goos() { + local target=${1:-${CHOST}} + case "${target}" in + *-linux*) echo linux ;; + *-darwin*) echo darwin ;; + *-freebsd*) echo freebsd ;; + *-netbsd*) echo netbsd ;; + *-openbsd*) echo openbsd ;; + *-solaris*) echo solaris ;; + *-cygwin*|*-interix*|*-winnt*) echo windows ;; + *) die "unknown GOOS for ${target}" ;; + esac +} + # @FUNCTION: go-env_goarch # @USAGE: [toolchain prefix] # @DESCRIPTION: -- 2.45.2