diff options
author | 2017-03-05 14:17:05 -0800 | |
---|---|---|
committer | 2017-03-05 14:17:05 -0800 | |
commit | 1e4ba588dc2e1e8b011ffe878977f5a909302bbe (patch) | |
tree | bda41335f3d2f2ba3d90b3c356b78cc9f518738e /Makefile | |
parent | 5eedb728dfdeebe5284af3760879aa3f054ffdb0 (diff) | |
download | coredns-1e4ba588dc2e1e8b011ffe878977f5a909302bbe.tar.gz coredns-1e4ba588dc2e1e8b011ffe878977f5a909302bbe.tar.zst coredns-1e4ba588dc2e1e8b011ffe878977f5a909302bbe.zip |
Enforce `go lint` check and fix several lint issues (#570)
This fix updates the Makefile to add the `go lint` check
for the build. This fix also fixes several go lint issues.
NOTE: This fix does not enforce `go lint` (suggestion only).
This fix also ignores the `go lint` error:
```
middleware/middleware.go:72:1: context.Context should be the first parameter of a function
```
as it requires too many changes in API.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -7,23 +7,27 @@ all: coredns # Phony this to ensure we always build the binary. # TODO: Add .go file dependencies. .PHONY: coredns -coredns: deps core/zmiddleware.go core/dnsserver/zdirectives.go +coredns: check core/zmiddleware.go core/dnsserver/zdirectives.go go build $(BUILD_VERBOSE) -ldflags="-s -w" .PHONY: deps -deps: fmt +deps: go get ${BUILD_VERBOSE} + go get -u github.com/golang/lint/golint + +.PHONY: check +check: fmt deps .PHONY: test -test: deps +test: check go test -race $(TEST_VERBOSE) ./test ./middleware/... .PHONY: testk8s -testk8s: deps +testk8s: check go test -race $(TEST_VERBOSE) -tags=k8s -run 'TestKubernetes' ./test ./middleware/kubernetes/... .PHONY: coverage -coverage: deps +coverage: check set -e -x echo "" > coverage.txt for d in `go list ./... | grep -v vendor`; do \ @@ -52,6 +56,11 @@ fmt: @test -z "$$(gofmt -s -l . | grep -v vendor/ | tee /dev/stderr)" || \ (echo "please format Go code with 'gofmt -s -w'" && false) +.PHONY: lint +lint: deps + ## run go lint, suggestion only (not enforced) + @test -z "$$(golint ./... | grep -v vendor/ | grep -v ".pb.go:" | grep -vE "context\.Context should be the first parameter of a function" | tee /dev/stderr)" + .PHONY: distclean distclean: clean # Clean all dependencies and build artifacts |