-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
54 lines (45 loc) · 1.08 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
.PHONY: default install build clean test fmt vet lint
default: build
build: check_go_version
go build -o ./bin/clientgofix $(shell ./build/print-ldflags.sh) ./
install: check_go_version
go install $(shell ./build/print-ldflags.sh) ./
clean:
rm -fr bin
test:
go test -v ./...
# Capture output and force failure when there is non-empty output
fmt:
@echo gofmt -l ./pkg
@OUTPUT=`gofmt -l ./pkg 2>&1`; \
if [ "$$OUTPUT" ]; then \
echo "gofmt must be run on the following files:"; \
echo "$$OUTPUT"; \
exit 1; \
fi
vet:
go vet ./pkg
# https://github.com/golang/lint
# go get github.com/golang/lint/golint
# Capture output and force failure when there is non-empty output
lint:
@echo golint ./...
@OUTPUT=`golint ./... 2>&1`; \
if [ "$$OUTPUT" ]; then \
echo "golint errors:"; \
echo "$$OUTPUT"; \
exit 1; \
fi
check_go_version:
@OUTPUT=`go version`; \
case "$$OUTPUT" in \
*"go1.13."*);; \
*"go1.14."*);; \
*"go1.15."*);; \
*"devel"*);; \
*) \
echo "Expected: go version go1.13.*, go1.14.*, go1.15.*, or devel"; \
echo "Found: $$OUTPUT"; \
exit 1; \
;; \
esac