• [gentoo-dev] [PATCH 7/8] go-env.eclass: Add the go-env_goos() helper fu

    From James Le Cuirot@21:1/5 to All on Tue Jul 9 23:20:01 2024
    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 <chewi@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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (2