Skip to content

Commit fa84bb5

Browse files
m1kolafealebenpae
authored andcommitted
Use go env GOPATH to read GOPATH (#4072)
Fixes and issue with go modules being installed into the project root during linting when `GOPATH` is not set.
1 parent 29d9b8c commit fa84bb5

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

scripts/evergreen/lint_code.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env bash
22
set -Eeou pipefail
33

4-
export GOPATH=${GOPATH:-${workdir}}
5-
64
# Set required version
75
required_version="v1.61.0"
86

@@ -17,10 +15,9 @@ fi
1715
echo "Go Version: $(go version)"
1816

1917
echo "Running golangci-lint..."
20-
if PATH=${GOPATH}/bin:${PATH} golangci-lint run --fix; then
18+
if PATH=$(go env GOPATH)/bin:${PATH} golangci-lint run --fix; then
2119
echo "No issues found by golangci-lint."
2220
else
2321
echo "golangci-lint found issues or made changes."
2422
exit 1
2523
fi
26-

scripts/evergreen/update_licenses.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ process_licenses() {
2020
return 1
2121
fi
2222

23-
PATH=${GOPATH}/bin:${PATH} GOOS=linux GOARCH=amd64 GOFLAGS="-mod=mod" go-licenses report . --template "${SCRIPTS_DIR}/update_licenses.tpl" > licenses_full.csv 2> licenses_stderr || true
23+
PATH=$(go env GOPATH)/bin:${PATH} GOOS=linux GOARCH=amd64 GOFLAGS="-mod=mod" go-licenses report . --template "${SCRIPTS_DIR}/update_licenses.tpl" > licenses_full.csv 2> licenses_stderr || true
2424

2525
# Filter and sort the licenses report
2626
grep -v 10gen licenses_full.csv | grep -v "github.com/mongodb" | grep -v "^golang.org" | sort > licenses.csv || true

0 commit comments

Comments
 (0)