-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
57 lines (43 loc) · 1.65 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
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
.PHONY: audit build clean code-sec delimiter fmt lint run test update help
audit: ## Audits and finds vulnerable dependencies
govulncheck ./...
build: Dockerfile ## Builds ./Dockerfile image name: project
docker build -t project .
build-bin: Dockerfile ## Builds ./Dockerfile image name: project
go build -o build/main
clean: ## Removes /bin folder
rm -fr ./build
rm -fr ./vendor
code-sec: ## Checks code for security issues
gosec ./...
delimiter-%:
@echo '===================${GREEN} $* ${RESET}==================='
fmt: ## Formats the code using go fmt and go vet
go fmt ./...
go vet ./...
lint: ## Automated checking of your source code for programmatic and stylistic errors
golangci-lint run ./...
run: ## Run the app locally
go run .
run-container: build ## First builds ./Dockerfile with image name: project and then runs a container, with name: project_container, on port :28700
docker run -p :3333:3333 --name project_container -ti --rm project
test: ## Runs standard unit test tests
go test -race -cover -v ./...
update: ## Go gets all of the dependencies and downloads them
go get .
go mod download
help: ## Show this help
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)