-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lint: replace deprecated golang.org/x/lint/golint with golangci-lint
golint is deprecated. golangci-lint is a more than adequate replacement. Because it combines different linters, a single invocation in the Makefile is enough and then produces consistent output for all of them. It also gets enabled as a GitHub action. This will annotate pull requests. The godox linter gets enabled as replacement for the manual "grep -i fixme". For the sake of convenience, "make lint" installs golangci-lint. In contrast to golint before, this is done without polluting the go.mod file with the extra dependencies.
- Loading branch information
Showing
7 changed files
with
40 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: golangci-lint | ||
on: | ||
push: | ||
tags: | ||
- v* | ||
branches: | ||
- master | ||
pull_request: | ||
permissions: | ||
contents: read | ||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
- uses: actions/checkout@v3 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version | ||
# When bumping this, then also bump the version in the Makefile's "go install". | ||
version: v1.51.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
linters: | ||
enable: | ||
- godox | ||
- gofmt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export GOBIN ?= $(shell pwd)/bin | ||
|
||
GOLINT = $(GOBIN)/golint | ||
GOLINT = $(GOBIN)/golangci-lint | ||
|
||
GO_FILES := $(shell \ | ||
find . '(' -path '*/.*' -o -path './vendor' ')' -prune \ | ||
|
@@ -24,18 +24,16 @@ cover: | |
go test -race -coverprofile=cover.out -coverpkg=./... ./... | ||
go tool cover -html=cover.out -o cover.html | ||
|
||
# Note that installation via "go install" is not recommended | ||
# (https://golangci-lint.run/usage/install/#install-from-source). | ||
# If this causes problems, install a pre-built binary. | ||
# | ||
# When bumping the version here, then also bump the version in | ||
# .github/workflows/golangci-lint.yml | ||
$(GOLINT): | ||
go install golang.org/x/lint/golint | ||
go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
|
||
.PHONY: lint | ||
lint: $(GOLINT) | ||
@rm -rf lint.log | ||
@echo "Checking formatting..." | ||
@gofmt -d -s $(GO_FILES) 2>&1 | tee lint.log | ||
@echo "Checking vet..." | ||
@go vet ./... 2>&1 | tee -a lint.log | ||
@echo "Checking lint..." | ||
@$(GOLINT) ./... 2>&1 | tee -a lint.log | ||
@echo "Checking for unresolved FIXMEs..." | ||
@git grep -i fixme | grep -v -e '^vendor/' -e '^Makefile' | tee -a lint.log | ||
@[ ! -s lint.log ] | ||
@$(GOLINT) run ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.