forked from akamai/AkamaiOPEN-edgegrid-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (30 loc) · 888 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
BIN = $(CURDIR)/bin
GO = go
Q = $(if $(filter 1,$V),,@)
clean-tools:
@rm -rf $(BIN)/go*
$(BIN):
@mkdir -p $@
$(BIN)/%: | $(BIN) ; $(info $(M) Building $(PACKAGE)...)
$Q tmp=$$(mktemp -d); \
env GO111MODULE=off GOPATH=$$tmp GOBIN=$(BIN) $(GO) get $(PACKAGE) \
|| ret=$$?; \
rm -rf $$tmp ; exit $$ret
GOIMPORTS = $(BIN)/goimports
$(BIN)/goimports: PACKAGE=golang.org/x/tools/cmd/goimports
.PHONY: all
all: fmt-check test
.PHONY: test
test: ; $(info > Running tests...) @
go test -v ./...
.PHONY: fmt
fmt: | $(GOIMPORTS); $(info $(M) Running goimports...) @
$Q $(GOIMPORTS) -w .
.PHONY: fmt-check
fmt-check: | $(GOIMPORTS); $(info $(M) Running format and imports check...) @
$(eval OUTPUT = $(shell $(GOIMPORTS) -l .))
@if [ "$(OUTPUT)" != "" ]; then\
echo "Found following files with incorrect format and/or imports:";\
echo "$(OUTPUT)";\
false;\
fi