-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (50 loc) · 1.06 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
GO ?= go
GOBIN ?= $(shell $(GO) env GOBIN)
GOPATH ?= $(shell $(GO) env GOPATH)
GOMOD := $(GO) mod
GOTEST := $(GO) test
GOFMT := gofmt
GOLINT := golangci-lint
APP_NAME = frate-go
BIN_DIR = ./bin
MAIN_SRC = ./main.go
BUILD_DIR = ./output
TEST_FLAGS ?= -v -cover
.PHONY: all
all: clean test build lint
.PHONY: run
run: $(MAIN_SRC)
$(GO) run $(MAIN_SRC)
.PHONY: build
build:
@echo "Building $(APP_NAME)..."
$(GO) build -o $(BUILD_DIR)/$(APP_NAME) .
.PHONY: install
install:
@echo "Installing $(APP_NAME) to $(GOBIN)..."
$(GO) install .
.PHONY: test
test:
@echo "Running tests..."
$(GOTEST) ./... $(TEST_FLAGS)
.PHONY: lint
lint:
@echo "Running linter..."
$(GOLINT) run
.PHONY: fmt
fmt:
@echo "Formatting code..."
$(GOFMT) -w $(GOFILES)
.PHONY: mod-tidy
mod-tidy:
$(GOMOD) tidy
.PHONY: mod-download
mod-download:
$(GOMOD) download
.PHONY: clean
clean:
@echo "Cleaning up..."
rm -rf $(BUILD_DIR) $(BIN_DIR)
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'