-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
34 lines (28 loc) · 1.39 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
# test runs the Go tests for the current package and the tests package.
test:
go test -v ./tests
# run runs the example specified in the example variable with the optional arguments specified in the ARGS variable.
run:
go run examples/$(example)/*.go $(ARGS)
# vet runs the Go vet static analysis tool on all packages in the project.
vet:
go vet -v ./...
# lint runs the staticcheck and golint static analysis tools on all packages in the project.
lint:
$(call check_command_exists,staticcheck) && staticcheck ./...
$(call check_command_exists,golint) || go install -v golang.org/x/lint/golint
golint ./...
# check_command_exists is a helper function that checks if a command exists.
check_command_exists = $(shell command -v $(1) > /dev/null && echo "true" || echo "false")
ifeq ($(call check_command_exists,$(1)),false)
$(error "$(1) command not found")
endif
# help prints a list of available targets and their descriptions.
help:
@echo "Available targets:"
@echo
@echo "test Run Go tests for the current package and the tests package."
@echo "run Run the example specified in the example variable with optional arguments specified in the ARGS variable."
@echo "vet Run the Go vet static analysis tool on all packages in the project."
@echo "lint Run the staticcheck and golint static analysis tools on all packages in the project."
@echo "help Print this help message."