khenaidoo | 2672188 | 2021-08-11 17:42:52 -0400 | [diff] [blame] | 1 | PKGS := github.com/pkg/errors |
| 2 | SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS)) |
| 3 | GO := go |
| 4 | |
| 5 | check: test vet gofmt misspell unconvert staticcheck ineffassign unparam |
| 6 | |
| 7 | test: |
| 8 | $(GO) test $(PKGS) |
| 9 | |
| 10 | vet: | test |
| 11 | $(GO) vet $(PKGS) |
| 12 | |
| 13 | staticcheck: |
| 14 | $(GO) get honnef.co/go/tools/cmd/staticcheck |
| 15 | staticcheck -checks all $(PKGS) |
| 16 | |
| 17 | misspell: |
| 18 | $(GO) get github.com/client9/misspell/cmd/misspell |
| 19 | misspell \ |
| 20 | -locale GB \ |
| 21 | -error \ |
| 22 | *.md *.go |
| 23 | |
| 24 | unconvert: |
| 25 | $(GO) get github.com/mdempsky/unconvert |
| 26 | unconvert -v $(PKGS) |
| 27 | |
| 28 | ineffassign: |
| 29 | $(GO) get github.com/gordonklaus/ineffassign |
| 30 | find $(SRCDIRS) -name '*.go' | xargs ineffassign |
| 31 | |
| 32 | pedantic: check errcheck |
| 33 | |
| 34 | unparam: |
| 35 | $(GO) get mvdan.cc/unparam |
| 36 | unparam ./... |
| 37 | |
| 38 | errcheck: |
| 39 | $(GO) get github.com/kisielk/errcheck |
| 40 | errcheck $(PKGS) |
| 41 | |
| 42 | gofmt: |
| 43 | @echo Checking code is gofmted |
| 44 | @test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)" |