Skip to content

Commit

Permalink
Fix "if modules enabled" check in common.sh
Browse files Browse the repository at this point in the history
The code `(go mod edit -json &>/dev/null)` fails if modules are not
enabled because of `set -o errexit`. This commit fixes it so the script
continues its execution.
  • Loading branch information
hypnoglow committed Jan 27, 2020
1 parent cf950d8 commit fd794bf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ set -o nounset
set -o pipefail

# check if modules are enabled
(go mod edit -json &>/dev/null)
MODULES_ENABLED=$?
MODULES_ENABLED=""
if go mod edit -json &>/dev/null ; then
MODULES_ENABLED="1"
fi

MOD_OPT=""
MODULES_OPT=${MODULES_OPT:-""}
if [[ -n "${MODULES_OPT}" && $MODULES_ENABLED ]]; then
if [[ -n "${MODULES_OPT}" && -n "${MODULES_ENABLED}" ]]; then
MOD_OPT="-mod=${MODULES_OPT}"
fi

Expand Down

0 comments on commit fd794bf

Please sign in to comment.