Skip to content

Commit

Permalink
Use golangci-lint instead of golint
Browse files Browse the repository at this point in the history
We have been using golint as a linter, but golint was officially deprecated.
golang/go#38968

The revive is a drop-in replacement of golint.
https://github.com/mgechev/revive

It's possible to use revive as it is, but I'd like to use revive via
golangci-lint so that we can add more linters easily.
https://github.com/golangci/golangci-lint

The golangci-lint is a meta linter.
I'll take this opportunity to introduce some additional checks.
  • Loading branch information
minamijoyo committed Jan 20, 2022
1 parent eea6c34 commit be57931
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 230 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: lint
permissions:
contents: read
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.43.0
12 changes: 12 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://golangci-lint.run/usage/configuration/
linters:
disable-all: true
enable:
- errcheck
- goimports
- gosec
- gosimple
- govet
- ineffassign
- revive
- staticcheck
22 changes: 5 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
NAME := tfschema

ifndef GOBIN
GOBIN := $(shell echo "$${GOPATH%%:*}/bin")
endif

GOLINT := $(GOBIN)/golint

$(GOLINT): ; @go install golang.org/x/lint/golint

.DEFAULT_GOAL := build

.PHONY: deps
Expand All @@ -23,20 +15,16 @@ install: deps
go install

.PHONY: lint
lint: $(GOLINT)
golint $$(go list ./... | grep -v /vendor/)

.PHONY: vet
vet:
go vet ./...
lint:
golangci-lint run ./...

.PHONY: test
test: deps
test: build
go test ./...

.PHONY: testacc
testacc: deps
testacc: build
TEST_ACC=1 go test -count=1 -failfast ./...

.PHONY: check
check: lint vet test build
check: lint test
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ require (
github.com/pkg/browser v0.0.0-20201207095918-0426ae3fba23
github.com/posener/complete v1.2.1
github.com/zclconf/go-cty v1.8.1
golang.org/x/lint v0.0.0-20200302205851-738671d3881b
)

replace (
Expand Down
Loading

0 comments on commit be57931

Please sign in to comment.