14
14
GO ?= go
15
15
GOFMT ?= $(GO ) fmt
16
16
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO ) env GOPATH) ) )
17
- PROMU := $(FIRST_GOPATH ) /bin/promu
18
- STATICCHECK := $(FIRST_GOPATH ) /bin/staticcheck
19
- GOVENDOR := $(FIRST_GOPATH ) /bin/govendor
17
+ PROMU := bin/promu
18
+ STATICCHECK := bin/staticcheck
20
19
pkgs = ./...
21
20
22
21
PREFIX ?= $(shell pwd)
23
22
BIN_DIR ?= $(shell pwd)
24
23
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD) )
25
24
DOCKER_IMAGE_NAME ?= postgres-exporter
26
25
27
- all : vet style staticcheck unused build test
26
+ all : vet style staticcheck build test
28
27
29
28
style :
30
29
@echo " >> checking code style"
31
- ! $(GOFMT ) -d $$(find . -path ./vendor -prune -o - name '*.go' -print ) | grep ' ^'
30
+ ! $(GOFMT ) -d $$(find . -name '*.go' -print ) | grep ' ^'
32
31
33
32
check_license :
34
33
@echo " >> checking license header"
35
- @licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*' ) ; do \
34
+ @licRes=$$(for file in $$(find . -type f -iname '*.go' ) ; do \
36
35
awk 'NR<=3' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \
37
36
done); \
38
37
if [ -n "$${licRes}" ]; then \
58
57
59
58
staticcheck : $(STATICCHECK )
60
59
@echo " >> running staticcheck"
61
- $(STATICCHECK ) $(pkgs )
62
-
63
- unused : $(GOVENDOR )
64
- @echo " >> running check for unused packages"
65
- @$(GOVENDOR ) list +unused | grep . && exit 1 || echo ' No unused packages'
60
+ GOOS= GOARCH= $(GO ) build -modfile=tools/go.mod -o bin/staticcheck honnef.co/go/tools/cmd/staticcheck
61
+ bin/staticcheck $(pkgs )
66
62
67
63
build : promu
68
64
@echo " >> building binaries"
@@ -77,12 +73,6 @@ docker:
77
73
docker build -t " $( DOCKER_IMAGE_NAME) :$( DOCKER_IMAGE_TAG) " .
78
74
79
75
promu :
80
- GOOS= GOARCH= $(GO ) get -u github.com/prometheus/promu
81
-
82
- $(FIRST_GOPATH ) /bin/staticcheck :
83
- GOOS= GOARCH= $(GO ) get -u honnef.co/go/tools/cmd/staticcheck
84
-
85
- $(FIRST_GOPATH ) /bin/govendor :
86
- GOOS= GOARCH= $(GO ) get -u github.com/kardianos/govendor
76
+ GOOS= GOARCH= $(GO ) build -modfile=tools/go.mod -o bin/promu github.com/prometheus/promu
87
77
88
- .PHONY : all style check_license format build test vet assets tarball docker promu staticcheck $( FIRST_GOPATH ) / bin/staticcheck govendor $( FIRST_GOPATH ) /bin/govendor
78
+ .PHONY : all style check_license format build test vet assets tarball docker promu staticcheck bin/staticcheck
0 commit comments