1 export GO15VENDOREXPERIMENT=1
3 BENCH_FLAGS ?= -cpuprofile=cpu.pprof -memprofile=mem.pprof -benchmem
4 PKGS ?= $(shell glide novendor)
5 # Many Go tools take file globs or directories as arguments instead of packages.
6 PKG_FILES ?= *.go zapcore benchmarks buffer zapgrpc zaptest zaptest/observer internal/bufferpool internal/exit internal/color internal/ztest
8 # The linting tools evolve with each Go version, so run them only on the latest
10 GO_VERSION := $(shell go version | cut -d " " -f 3)
11 GO_MINOR_VERSION := $(word 2,$(subst ., ,$(GO_VERSION)))
12 LINTABLE_MINOR_VERSIONS := 10
13 ifneq ($(filter $(LINTABLE_MINOR_VERSIONS),$(GO_MINOR_VERSION)),)
23 @echo "Installing Glide and locked dependencies..."
24 glide --version || go get -u -f github.com/Masterminds/glide
26 @echo "Installing test dependencies..."
27 go install ./vendor/github.com/axw/gocov/gocov
28 go install ./vendor/github.com/mattn/goveralls
30 @echo "Installing golint..."
31 go install ./vendor/github.com/golang/lint/golint
33 @echo "Not installing golint, since we don't expect to lint on" $(GO_VERSION)
36 # Disable printf-like invocation checking due to testify.assert.Error()
37 VET_RULES := -printf=false
43 @echo "Checking formatting..."
44 @gofmt -d -s $(PKG_FILES) 2>&1 | tee lint.log
45 @echo "Installing test dependencies for vet..."
47 @echo "Checking vet..."
48 @$(foreach dir,$(PKG_FILES),go tool vet $(VET_RULES) $(dir) 2>&1 | tee -a lint.log;)
49 @echo "Checking lint..."
50 @$(foreach dir,$(PKGS),golint $(dir) 2>&1 | tee -a lint.log;)
51 @echo "Checking for unresolved FIXMEs..."
52 @git grep -i fixme | grep -v -e vendor -e Makefile | tee -a lint.log
53 @echo "Checking for license headers..."
54 @./check_license.sh | tee -a lint.log
57 @echo "Skipping linters on" $(GO_VERSION)
66 ./scripts/cover.sh $(PKGS)
71 @$(foreach pkg,$(PKGS),go test -bench=$(BENCH) -run="^$$" $(BENCH_FLAGS) $(pkg);)
76 cat .readme.tmpl | go run internal/readme/readme.go > README.md