[Makefile] Rules for Linters of Golang Source Code


Example [1] of Makefile rules for Go linters. Make it a post for search engine friendliness.

PACKAGES=$(shell go list ./... | grep -v /vendor)

check:  ## Check the code using various linters and static checkers.
      @echo "Running gofmt..."
      @gofmt -d $(shell find . -type f -name '*.go' -not -path "./vendor/*")

      @echo "Running go vet..."
      @for package in $(PACKAGES);  do \
              go vet -v $$package || exit 1; \
      done

      @echo "Running golint..."
      @for package in $(PACKAGES); do \
              golint -set_exit_status $$package || exit 1; \
      done

      @echo "Running errcheck..."
      @for package in $(PACKAGES); do \
              errcheck -ignore 'Close' -ignoretests $$package || exit 1; \
      done

References:

[1]Orange_Tux comments on Linters do not get attention they deserve
[2]Linters do not get attention they deserve : golang