-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (42 loc) · 1.04 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
.PHONY: \
all \
deps \
lint \
test
MKFILE_DIR := $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
SOURCES := "."
TEST_FILTER := Test
all: deps format lint test
format:
@ echo "Formatting source code"
git ls-files "**.go" | xargs -n1 gofmt -e -s -w
fgt:
@ if ! which fgt > /dev/null; then \
echo "fgt not found, attempting to install" >&2; \
if ! go get github.com/GeertJohan/fgt; then \
exit 1; \
fi \
fi
fgt
lint: fgt
@ if ! which golint > /dev/null; then \
echo "Golint not found, attempting to install" >&2; \
if ! go get github.com/golang/lint/golint; then \
exit 1; \
fi \
fi
@ echo "Linting source code"
echo $(SOURCES) | xargs -n1 fgt golint
test:
@ echo "Running unit tests"
go test -v $(SOURCES)
deps: fgt
@ echo "Restoring source dependencies (requires 'dep')"
@ echo " See https://github.com/golang/dep"
@ if ! which dep > /dev/null; then \
echo "dep not found, attempting to install" >&2; \
if ! go get -u github.com/golang/dep/cmd/dep; then \
exit 1; \
fi \
fi
@ dep ensure