-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (49 loc) · 1.07 KB
/
Makefile
File metadata and controls
62 lines (49 loc) · 1.07 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Variables
PROJECT_NAME := goTesting
BINARY_NAME := $(PROJECT_NAME)
GO_FILES := $(shell find . -name '*.go' -not -path "./vendor/*")
# Default target
all: build
# Build the project
build:
go build -o bin/$(BINARY_NAME)
# Run the project
run: build
./bin/$(BINARY_NAME)
# Test the project
test:
go test ./...
# Format the code
fmt:
go fmt $(GO_FILES)
# Clean the project
clean:
go clean
rm -f bin/$(BINARY_NAME)
# Install dependencies
deps:
go mod tidy
go mod download
# Coverage
coverage:
go clean -testcache
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
# Lint the code
lint:
golangci-lint run
# Run all checks
check: fmt lint test
# Build for multiple platforms
build-multiarch:
GOOS=linux GOARCH=amd64 go build -o bin/$(BINARY_NAME)_linux_amd64
GOOS=darwin GOARCH=amd64 go build -o bin/$(BINARY_NAME)_darwin_amd64
GOOS=windows GOARCH=amd64 go build -o bin/$(BINARY_NAME)_windows_amd64.exe
# Install the binary in $GOPATH/bin
install: build
go install
# Update dependencies
update-deps:
go get -u ./...
go mod tidy
go mod download