代码拉取完成,页面将自动刷新
IGNORE_MOD_DIR := ./cmd/woco
ALL_GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
GO_MOD_DIRS := $(filter-out $(IGNORE_MOD_DIR), $(ALL_GO_MOD_DIRS))
ALL_COVERAGE_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | sort)
COVERAGE_MOD_DIRS := $(filter-out $(IGNORE_MOD_DIR), $(ALL_COVERAGE_MOD_DIRS))
COVERAGE_MODE = atomic
COVERAGE_PROFILE = coverage.out
GO = go
TIMEOUT = 60
# Build
.PHONY: build
build: $(GO_MOD_DIRS:%=build/%)
build/%:
@echo "$(GO) build ./..." \
&& cd ./ \
&& $(GO) build ./...
build/%: DIR=$*
build/%:
@echo "$(GO) build $(DIR)/..." \
&& cd $(DIR) \
&& $(GO) build ./...
# Tests
TEST_TARGETS := test-default test-bench test-short test-verbose test-race
.PHONY: $(TEST_TARGETS) test
test-default test-race: ARGS=-race
test-bench: ARGS=-run=xxxxxMatchNothingxxxxx -test.benchtime=1ms -bench=
test-short: ARGS=-short
test-verbose: ARGS=-v
$(TEST_TARGETS): test
test: test-root $(GO_MOD_DIRS:%=test/%)
test-root:
@echo "$(GO) test -timeout $(TIMEOUT)s $(ARGS) ./..." \
&& cd ./ \
&& $(GO) test -timeout $(TIMEOUT)s $(ARGS) ./...
test/%: DIR=$*
test/%:
@echo "$(GO) test -timeout $(TIMEOUT)s $(ARGS) -covermode=$(COVERAGE_MODE) -coverprofile=$(COVERAGE_PROFILE) $(DIR)/..." \
&& cd $(DIR) \
&& $(GO) test -timeout $(TIMEOUT)s $(ARGS) -covermode=$(COVERAGE_MODE) -coverprofile=$(COVERAGE_PROFILE) ./...
.PHONY: test-coverage
test-coverage: $(COVERAGE_MOD_DIRS:%=test-coverage/%)
test-coverage/%:
@echo "$(GO) test -timeout $(TIMEOUT)s $(ARGS) -covermode=$(COVERAGE_MODE) -coverprofile=$(COVERAGE_PROFILE) ./..." \
&& cd ./ \
&& $(GO) test -timeout $(TIMEOUT)s $(ARGS) -covermode=$(COVERAGE_MODE) -coverprofile=$(COVERAGE_PROFILE) ./...
test-coverage/%: DIR=$*
test-coverage/%:
@echo "$(GO) test -timeout $(TIMEOUT)s $(ARGS) -covermode=$(COVERAGE_MODE) -coverprofile=$(COVERAGE_PROFILE) $(DIR)/..." \
&& cd $(DIR) \
&& $(GO) test -timeout $(TIMEOUT)s $(ARGS) -covermode=$(COVERAGE_MODE) -coverprofile=$(COVERAGE_PROFILE) ./...
golangci-lint:
cd ./ \
&& golangci-lint run
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。