1#!/usr/bin/env bash 2 3set -e 4 5# Top level problems with modules can lead to test_lib being not functional 6go mod tidy 7 8source ./scripts/test_lib.sh 9source ./scripts/updatebom.sh 10 11# To fix according to newer version of go: 12# go get golang.org/dl/gotip 13# gotip download 14# GO_CMD="gotip" 15GO_CMD="go" 16 17function mod_tidy_fix { 18 run rm ./go.sum 19 run ${GO_CMD} mod tidy || return 2 20} 21 22function bash_ws_fix { 23 TAB=$'\t' 24 25 log_callout "Fixing whitespaces in the bash scripts" 26 # Makes sure all bash scripts do use ' ' (double space) for indention. 27 log_cmd "find ./ -name '*.sh' -print0 | xargs -0 sed -i.bak 's|${TAB}| |g'" 28 find ./ -name '*.sh' -print0 | xargs -0 sed -i.bak "s|${TAB}| |g" 29 find ./ -name '*.sh.bak' -print0 | xargs -0 rm 30} 31 32log_callout -e "\\nFixing etcd code for you...\\n" 33 34run_for_modules mod_tidy_fix || exit 2 35run_for_modules run ${GO_CMD} fmt || exit 2 36run_for_module tests bom_fix || exit 2 37bash_ws_fix || exit 2 38 39log_success -e "\\nSUCCESS: etcd code is fixed :)" 40