Skip to content

Commit e48a1b1

Browse files
committed
Make go:lint task compatible with Go 1.16
The update from Go 1.14 to 1.16 broke the task that runs golint. The good news is that the new `go install` command eliminates the need for the workaround of running the `go get golang.org/x/lint/golint` command from outside the project path. The bad news is the `go list` command used to get the path of the golint installation does not work in the "module-aware mode" that is now the default. In the end, I gave up on making the task work as before. I think it's better to require the user to install golint and put the installation in the system PATH, displaying a helpful message when this has not been done.
1 parent e02295f commit e48a1b1

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

.github/workflows/check-go-task.yml

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ jobs:
8888
repo-token: ${{ secrets.GITHUB_TOKEN }}
8989
version: 3.x
9090

91+
- name: Install golint
92+
run: go install golang.org/x/lint/golint@latest
93+
9194
- name: Check style
9295
run: task --silent go:lint
9396

Taskfile.yml

+6-8
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,12 @@ tasks:
128128
desc: Lint Go code
129129
cmds:
130130
- |
131-
PROJECT_PATH="$PWD"
132-
# `go get` and `go list` commands must be run from a temporary folder to avoid polluting go.mod
133-
cd "$(mktemp -d "${TMPDIR-${TMP-/tmp}}/task-temporary-XXXXX")"
134-
go get golang.org/x/lint/golint
135-
GOLINT_PATH="$(go list -f '{{"{{"}}.Target{{"}}"}}' golang.org/x/lint/golint || echo "false")"
136-
# `golint` must be run from the module folder
137-
cd "$PROJECT_PATH"
138-
"$GOLINT_PATH" \
131+
if ! which golint &>/dev/null; then
132+
echo "golint not installed or not in PATH. Please install: https://github.com/golang/lint#installation"
133+
exit 1
134+
fi
135+
- |
136+
golint \
139137
{{default "-min_confidence 0.8 -set_exit_status" .GO_LINT_FLAGS}} \
140138
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
141139

0 commit comments

Comments
 (0)