-
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
GO_PACKAGE := github.com/6543/go-version
GO ?= go
GOFMT ?= gofmt -s
SHASUM ?= shasum -a 256
GO_SOURCES := $(shell find . -type f -name "*.go")
.PHONY: all
all: clean test
.PHONY: clean
clean:
$(GO) clean -i ./...
.PHONY: fmt
fmt:
$(GOFMT) -w $(GO_SOURCES)
.PHONY: fmt-check
fmt-check:
# get all go files and run go fmt on them
@diff=$$($(GOFMT) -d $(GO_SOURCES)); \
if [ -n "$$diff" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi;
.PHONY: lint
lint: vet revive misspell
.PHONY: vet
vet:
$(GO) vet $(GO_PACKAGE)
.PHONY: revive
revive:
$(GO) get -u github.com/mgechev/revive; \
revive -config .revive.toml || exit 1
.PHONY: misspell
misspell-check:
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
misspell -error -i unknwon,destory $(GO_SOURCES)
.PHONY: test
test:
$(GO) test -cover -coverprofile coverage.out || exit 1