mirror of
https://github.com/coredns/coredns.git
synced 2025-12-09 11:55:13 -05:00
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>
This commit is contained in:
19
Makefile
19
Makefile
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user