-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathMakefile
84 lines (69 loc) · 2.18 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
##
# Console Colors
##
GREEN := $(shell printf "\033[0;32m")
YELLOW := $(shell printf "\033[0;33m")
WHITE := $(shell printf "\033[0;37m")
CYAN := $(shell printf "\033[0;36m")
RESET := $(shell printf "\033[0m")
# Get the current working directory
CURRENT_DIR := $(CURDIR)
# Get the directory name of the current working directory
PROJECT_NAME := $(notdir $(CURRENT_DIR))
# Get the GOOS value
GOOS := $(shell go env GOOS)
# Determine the output file extension based on the GOOS value
ifeq ($(GOOS),windows)
EXT := .exe
else
EXT :=
endif
##
# Targets
##
.PHONY: help
help: ## show this help.
@echo "Project: $(PROJECT_NAME)"
@echo 'Usage:'
@echo " ${GREEN}make${RESET} ${YELLOW}<target>${RESET}"
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${GREEN}%-21s${YELLOW}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST) | sort
.PHONY: clean
clean: ## clean builds dir
@rm -rf "$(PROJECT_NAME)" "$(PROJECT_NAME).exe" dist/
.PHONY: check
check: test lint golangci ## Run all checks locally
.PHONY: update
update: ## Run dependency updates
@go get -u ./...
@go mod tidy
.PHONY: build ## Build the project
build: clean $(PROJECT_NAME)
$(PROJECT_NAME):
@go build -o $(PROJECT_NAME)$(EXT) .
.PHONY: test
test: ## Test the project
@go test -race ./...
.PHONY: lint
lint: golangci ## Run linter
.PHONY: fmt ## Format code
fmt:
@-go fmt ./...
@-go run github.com/daixiang0/[email protected] write .
@-go run mvdan.cc/[email protected] -l -w .
@-go run golang.org/x/tools/cmd/[email protected] -l -w .
@-go run github.com/bombsimon/wsl/v4/cmd/[email protected] -fix ./...
@-go run github.com/catenacyber/[email protected] --fix ./...
@-go run github.com/tetafro/godot/cmd/[email protected] -w .
@-go run github.com/4meepo/tagalign/cmd/[email protected] -fix -sort -order "json,koanf" ./...
@-go run github.com/golangci/golangci-lint/cmd/[email protected] run ./...
.PHONY: golangci
golangci:
@go run github.com/golangci/golangci-lint/cmd/[email protected] run ./...
.PHONY: 3rdpartylicenses
3rdpartylicenses:
@go run github.com/google/[email protected] save . --save_path=3rdpartylicenses