diff options
| author | Maciej Borzecki <maciej.zenon.borzecki@canonical.com> | 2022-03-31 13:37:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-31 08:37:33 -0300 |
| commit | 16317817b8494e82ed37e7ec5acf1a7810b8c7bb (patch) | |
| tree | 68d4b764ed42ea96d44c6e6c4711f94676ef56b9 | |
| parent | 34e0cd97d8e540d606095df53ee0abb5ccca830f (diff) | |
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 <maciej.zenon.borzecki@canonical.com> * run-checks: use "go install" when it is supported * drop unneeded go.{mod,sum} changes Co-authored-by: Michael Vogt <mvo@ubuntu.com>
| -rwxr-xr-x | run-checks | 19 |
1 files 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 |
