-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (66 loc) · 2.22 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
SHELL := /bin/sh
# The name of the executable (default is current directory name)
TARGET := $(shell echo $${PWD\#\#*/})
.DEFAULT_GOAL: $(TARGET)
# These will be provided to the target
VERSION := 0.0.1
BUILD := `git rev-parse HEAD`
# Use linker flags to provide version/build settings to the target
LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.Build=$(BUILD)"
# go source files, ignore vendor directory
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
PKGS_BY_PATH = $(shell go list ./... | grep -v /vendor/)
.PHONY: all build clean install uninstall fmt test coverage run help
.PHONY: tools lint doc tidy
all: version tools lint install
$(TARGET): $(SRC)
@go build $(LDFLAGS) -o $(TARGET)
help:
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@echo 'Available targets are:'
@echo ''
@echo ' help Show this help screen.'
@echo ' clean Remove binaries, artifacts and releases.'
@echo ' doc Start Go documentation server on port 8080.'
@echo ' tools Install tools needed by the project.'
@echo ' lint Runs go golangci-lint run ./..
@echo ' test Run unit tests, and check.'
@echo ' testverbose Run unit tests in verbose mode, and check.'
@echo ' coverage Report code tests coverage, and check.'
@echo ' build Build project for current platform.'
@echo ' tidy runs go mod tidy'
@echo ' fmt Run go fmt.'
@echo ' install Run go install'
@echo ' uninstall Force removes the artifact'
@echo ' version Checks the go version'
@echo ''
@echo 'Targets run by default are: checkall, install'
@echo ''
build: $(TARGET)
@true
clean: tidy
@rm -f $(TARGET)
tidy:
@go mod tidy
doc:
godoc -http=:8080 -index
install:
@go install $(LDFLAGS)
uninstall: clean
@rm -f $$(which ${TARGET})
fmt:
@gofmt -l -w $(SRC)
# to be installed prior to running
tools:
@go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
lint:
@golangci-lint run ./...
test: lint
@go test $(PKGS_BY_PATH)
testverbose: lint
@go test -v $(PKGS_BY_PATH)
coverage: lint
@go test -cover $(PKGS_BY_PATH)
version:
@go version