commit:     647059f7f484488693e7af9b61d5888382123a03
Author:     William Hubbs <williamh <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 25 14:29:08 2022 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Feb 25 14:30:01 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=647059f7

go-module.eclass: add helper function to call go

This function will cause the ebuild to die if Go fails.
Also, it outputs the go command that is being run.

Closes: https://bugs.gentoo.org/833497
Signed-off-by: William Hubbs <williamh <AT> gentoo.org>

 eclass/go-module.eclass | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass
index 53f4a0269421..66fe52c9ad72 100644
--- a/eclass/go-module.eclass
+++ b/eclass/go-module.eclass
@@ -184,6 +184,19 @@ declare -A -g _GOMODULE_GOSUM_REVERSE_MAP
 # If you enable GO_OPTIONAL, you have to set BDEPEND on >=dev-lang/go-1.12
 # for your package and call go-module_src_unpack manually.
 
+# @FUNCTION: ego
+# @USAGE: [<args>...]
+# @DESCRIPTION:
+# Call go, passing the supplied arguments.
+# This function dies if go fails. It also supports being called via 'nonfatal'.
+# If you need to call go directly in your ebuilds, this is the way it
+# should be done.
+ego() {
+       set -- go "$@"
+       echo "$@" >&2
+       "$@" || die -n "${*} failed"
+}
+
 # @FUNCTION: go-module_set_globals
 # @DESCRIPTION:
 # Convert the information in EGO_SUM for other usage in the ebuild.

Reply via email to