6

[Makefile] Rules for Linters of Golang Source Code

 2 years ago
source link: http://siongui.github.io/2017/05/10/makefile-rule-for-linter-of-go-source-code/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

[Makefile] Rules for Linters of Golang Source Code

May 10, 2017

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:

[2]Linters do not get attention they deserve : golang


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK