-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgo.mod.mk
More file actions
40 lines (34 loc) · 1.15 KB
/
go.mod.mk
File metadata and controls
40 lines (34 loc) · 1.15 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
# This makefile contains helper targets for go projects that are using go
# modules (without vendoring).
# If you use this file, you probably should also include go.mk.
# It expects the PROJECT_NAME variable to be defined, as it will be used as
# name for the artifact.
GO_MAIN_DIR ?= .
GO_MOD_DIR ?= .
PROJECT_NAME ?= $(shell basename $(dir $(abspath $(firstword $(MAKEFILE_LIST)))))
GO_TEST_SKIP_DIRECTORY ?=
## go-build: Build the go app
.PHONY: go-build
go-build: | go-dep-clean go-dep-download
@go build -v -o $(BUILD_DIR)/$(PROJECT_NAME) $(GO_MAIN_DIR)
## go-dep-clean: Remove unused go dependencies
.PHONY: go-dep-clean
go-dep-clean:
@go mod tidy
## go-dep-download: Download all go dependencies
.PHONY: go-dep-download
go-dep-download: | go-dep-clean
@go mod download
## go-dep-upgrade: Upgrade all go dependencies
.PHONY: go-dep-upgrade
go-dep-upgrade:
@go get -C $(GO_MOD_DIR) -u ./...
@go mod -C $(GO_MOD_DIR) tidy
## go-test: Run unit tests
.PHONY: go-test
go-test:
ifeq ($(GO_TEST_SKIP_DIRECTORY),)
@cd ${GO_MOD_DIR} && go test -gcflags=-l ./...
else
@cd ${GO_MOD_DIR} && go test -gcflags=-l `go list ./... | grep -v $(GO_TEST_SKIP_DIRECTORY)`
endif