-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
43 lines (31 loc) · 1.24 KB
/
Makefile
File metadata and controls
43 lines (31 loc) · 1.24 KB
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
#
# A Makefile to build, run and test Go code
#
.PHONY: default build fmt lint run run_race test clean vet docker_build docker_run docker_clean
# This makes the APP_NAME be the name of the current directory
# Ex. in path /home/dev/app/awesome-app the APP_NAME will be set to awesome-app
APP_NAME := $(notdir $(CURDIR))
default: build ## Build the binary
build: ## Build the binary
go build -o ./bin/${APP_NAME} ./src/*.go
build_windows: ## Build the binary for Windows
GOOS=windows GOARCH=amd64 go build -o ./bin/${APP_NAME}.exe ./src/*.go
run: build ## Build and run the binary
# Add your environment variable here
DEBUG=true \
./bin/${APP_NAME}
run_race: ## Run the binary with race condition checking enabled
# Add your environment variable here
DEBUG=true \
go run -race ./src/*.go
fmt: ## Format the code using `go fmt`
go fmt ./...
test: ## Run the tests
go test ./...
test_cover: ## Run tests with a coverage report
go test ./... -v -cover -covermode=count -coverprofile=./coverage.out
clean: ## Remove compiled binaries from bin/
rm -Rf ./bin/logs
rm ./bin/*
help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'