-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
47 lines (33 loc) · 1.36 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
SHELL := /bin/bash
export GO111MODULE=on
export GOPROXY=https://proxy.golang.org
.DEFAULT_GOAL: all
LDFLAGS=-ldflags "-s -w"
.PHONY: all build check clean format help serve test tidy
all: check test build ## Default target: check, test, build
build: ## Build all executables, located under ./bin/
@echo "Building..."
@CGO_ENABLED=0 go build -o ./bin/example -trimpath $(LDFLAGS) ./example/...
@CGO_ENABLED=0 go build -o ./bin/pocketbase -trimpath $(LDFLAGS) ./cmd/pocketbase/...
serve: build ## Run the pocketbase server
@echo "Running server..."
@./bin/pocketbase serve
clean: ## Remove all artifacts from ./bin/ and ./resources
@rm -rf ./bin/* ./resources/*
format: ## Format go code with goimports
@go install golang.org/x/tools/cmd/goimports@latest
@goimports -l -w .
test: ## Run tests
@go test -shuffle=on -race ./...
tidy: ## Run go mod tidy
@go mod tidy
check: ## Linting and static analysis
@if test ! -e ./bin/golangci-lint; then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh; \
fi
@./bin/golangci-lint run -c .golangci.yml
# TODO in 2023 check if govulncheck is a part of golangci-lint
@go install golang.org/x/vuln/cmd/govulncheck@latest
@govulncheck ./...
help: ## Show help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'