-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
71 lines (61 loc) · 1.84 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
PROJECT_NAME ?= gonq
GOOS ?= $(shell uname)
GOARCH ?= $(shell arch)
CGO_ENABLED ?= 0
BIN_NAME = "$(PROJECT_NAME)"
SRC_DIR = ./cmd
BIN_DIR = ./bin
format:
@echo "Formatting..."
@gofmt -s -w .
@echo "Done!"
install:
@echo "Installing dependencies..."
@go mod download && go mod verify
@echo "Done!"
tidy:
@echo "Tidying dependencies..."
@go mod tidy
@echo "Done!"
clean-cache:
@echo "Cleaning build and package cache..."
@go clean -modcache
@go clean -cache
@echo "Done!"
build:
@echo "Building api..."
@echo "GOOS = $(GOOS)"
@echo "GOARCH = $(GOARCH)"
@echo "CGO_ENABLED = $(CGO_ENABLED)"
@go build -o $(BIN_DIR)/$(BIN_NAME) -v -x $(SRC_DIR)/${PROJECT_NAME}/.
@echo "Built!"
clean:
@echo "Cleaning..."
@go clean
@rm -rf $(BIN_DIR)/*
@echo "Cleaned!"
help:
@echo "-------------------------------------------------------------------------"
@echo " ${PROJECT_NAME} makefile"
@echo "-------------------------------------------------------------------------"
@echo ""
@echo "Make available targets:"
@echo " format : Format all project tree."
@echo ""
@echo " install : Installs the projects dependencies."
@echo " tidy : Tidy projects dependencies."
@echo " clean-cache : Cleans project cache."
@echo ""
@echo " build : Builds the binary for the specified GOOS and GOARCH."
@echo ""
@echo " clean : Cleans up generated files related to the binary."
@echo ""
@echo "Usage:"
@echo " make <target> [VARIABLE=value]"
@echo ""
@echo "Variables available for override (with defaults):"
@echo "PROJECT_NAME = $(PROJECT_NAME)"
@echo "GOOS = $(GOOS)"
@echo "GOARCH = $(GOARCH)"
@echo "CGO_ENABLED = $(CGO_ENABLED)"
@echo "-------------------------------------------------------------------------"