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 27, 2022
1 parent 7674ec6 commit 98e35b5
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 45 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
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: test
run: make check
run: make test
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
28 changes: 5 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
NAME := myaws

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

GOLINT := $(GOBIN)/golint
INEFFASSIGN := $(GOBIN)/ineffassign

$(GOLINT): ; @go install github.com/golang/lint/golint
$(INEFFASSIGN): ; @go install github.com/gordonklaus/ineffassign

.DEFAULT_GOAL := build

.PHONY: deps
Expand All @@ -21,20 +11,12 @@ build: deps
go build -o bin/$(NAME)

.PHONY: lint
lint: $(GOLINT)
@golint ./...

.PHONY: ineffassign
ineffassign: $(INEFFASSIGN)
@ineffassign ./

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

.PHONY: test
test:
@go test ./...
test: build
go test ./...

.PHONY: check
check: lint ineffassign vet test build
check: lint test
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ go 1.17
require (
github.com/aws/aws-sdk-go v1.38.39
github.com/dustin/go-humanize v1.0.0
github.com/golang/lint v0.0.0-20190301231843-5614ed5bae6f
github.com/gordonklaus/ineffassign v0.0.0-20190601041439-ed7b1b5ee0f8
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v0.0.5
github.com/spf13/viper v1.3.2
Expand All @@ -26,10 +24,8 @@ require (
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.3 // indirect
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f // indirect
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/tools v0.0.0-20190307163923-6a08e3108db3 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
)
9 changes: 0 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/golang/lint v0.0.0-20190301231843-5614ed5bae6f h1:w8/jB3pyg9PLwwPGAqpfhLMJFIm6h8+W65Z6zf10sSs=
github.com/golang/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
github.com/gordonklaus/ineffassign v0.0.0-20190601041439-ed7b1b5ee0f8 h1:ehVe1P3MbhHjeN/Rn66N2fGLrP85XXO1uxpLhv0jtX8=
github.com/gordonklaus/ineffassign v0.0.0-20190601041439-ed7b1b5ee0f8/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
Expand Down Expand Up @@ -62,9 +58,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f h1:hX65Cu3JDlGH3uEdK7I99Ii+9kjD6mvnnpfLdEAH0x4=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
Expand All @@ -80,8 +73,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190307163923-6a08e3108db3 h1:2oZsfYnKfYzL4I57uYiRFsUf0bqlLkiuw8nnj3+voUA=
golang.org/x/tools v0.0.0-20190307163923-6a08e3108db3/go.mod h1:25r3+/G6/xytQM8iWZKq3Hn0kr0rgFKPUNVEL/dr3z4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
8 changes: 0 additions & 8 deletions tools.go

This file was deleted.

0 comments on commit 98e35b5

Please sign in to comment.