From 16317817b8494e82ed37e7ec5acf1a7810b8c7bb Mon Sep 17 00:00:00 2001 From: Maciej Borzecki Date: Thu, 31 Mar 2022 13:37:33 +0200 Subject: run-check: use go install instead of go get (#11570) * run-check: use go install instead of go get With modules support, go get does not install a given package, but rather adds it to go.mod as dependency. Signed-off-by: Maciej Borzecki * run-checks: use "go install" when it is supported * drop unneeded go.{mod,sum} changes Co-authored-by: Michael Vogt --- run-checks | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/run-checks b/run-checks index 5fb916e853..eb90df3f3b 100755 --- a/run-checks +++ b/run-checks @@ -71,6 +71,19 @@ addtrap() { trap "store_exit_code; $CURRENTTRAP ; exit_with_exit_code" EXIT } +goinstall() { + pkg="$1" + # go1.18+ will no longer build/install packages. Here "go install" + # must be used but it will only fetch remote packages if the @latest + # (or similar syntax is used). Instead of checking the version we + # check if the "go install" help mentions this new feature. + if go help install | grep -q @latest; then + go install "${pkg}"@latest + else + go get -u "${pkg}" + fi +} + endmsg() { if [ $EXIT_CODE -eq 0 ]; then p="success.txt" @@ -210,7 +223,7 @@ if [ "$STATIC" = 1 ]; then echo "Checking spelling errors" if ! command -v misspell >/dev/null; then - go get -u github.com/client9/misspell/cmd/misspell + goinstall github.com/client9/misspell/cmd/misspell fi # FIXME: auter is only misspelled in the changelog so we should fix there # PROCES is used in the seccomp tests (PRIO_PROCES{,S,SS}) @@ -222,7 +235,7 @@ if [ "$STATIC" = 1 ]; then if dpkg --compare-versions "$(go version | awk '$3 ~ /^go[0-9]/ {print substr($3, 3)}')" ge 1.12; then echo "Checking for ineffective assignments" if ! command -v ineffassign >/dev/null; then - go get -u github.com/gordonklaus/ineffassign + goinstall github.com/gordonklaus/ineffassign fi # ineffassign knows about ignoring vendor/ \o/ ineffassign ./... @@ -230,7 +243,7 @@ if [ "$STATIC" = 1 ]; then echo "Checking for naked returns" if ! command -v nakedret >/dev/null; then - go get -u github.com/alexkohler/nakedret + goinstall github.com/alexkohler/nakedret fi got=$(go list ./... | grep -v '/osutil/udev/' | grep -v '/vendor/' | xargs nakedret 2>&1) if [ -n "$got" ]; then -- cgit v1.2.3