forked from TrueCloudLab/basic
fixup: Add fumpt, gopls and staticcheck Make scenarios
This commit is contained in:
parent
fedaf59bb8
commit
9d574a3aa4
4 changed files with 61 additions and 5 deletions
19
mk/fumpt.mk
Normal file
19
mk/fumpt.mk
Normal file
|
@ -0,0 +1,19 @@
|
|||
BIN ?= bin
|
||||
GOFUMPT_VERSION ?= v0.7.0
|
||||
GOFUMPT_DIR ?= $(abspath $(BIN))/gofumpt
|
||||
GOFUMPT_VERSION_DIR ?= $(GOFUMPT_DIR)/$(GOFUMPT_VERSION)
|
||||
|
||||
.PHONY: fumpt fumpt-install
|
||||
|
||||
# Install gofumpt
|
||||
fumpt-install:
|
||||
@rm -rf $(GOFUMPT_DIR)
|
||||
@mkdir $(GOFUMPT_DIR)
|
||||
@GOBIN=$(GOFUMPT_VERSION_DIR) go install mvdan.cc/gofumpt@$(GOFUMPT_VERSION)
|
||||
|
||||
$(GOFUMPT_VERSION_DIR): fumpt-install
|
||||
|
||||
# Run gofumpt
|
||||
fumpt: $(GOFUMPT_VERSION_DIR)
|
||||
@echo "⇒ Processing gofumpt check"
|
||||
$(GOFUMPT_VERSION_DIR)/gofumpt -l -w cmd/ pkg/ misc/
|
24
mk/gopls.mk
Normal file
24
mk/gopls.mk
Normal file
|
@ -0,0 +1,24 @@
|
|||
BIN ?= bin
|
||||
GOPLS_VERSION ?= v0.15.1
|
||||
GOPLS_DIR ?= $(abspath $(BIN))/gopls
|
||||
GOPLS_VERSION_DIR ?= $(GOPLS_DIR)/$(GOPLS_VERSION)
|
||||
GOPLS_TEMP_FILE := $(shell mktemp)
|
||||
|
||||
.PHONY: gopls-install gopls-run
|
||||
|
||||
# Install gopls
|
||||
gopls-install:
|
||||
@rm -rf $(GOPLS_DIR)
|
||||
@mkdir $(GOPLS_DIR)
|
||||
@GOBIN=$(GOPLS_VERSION_DIR) go install golang.org/x/tools/gopls@$(GOPLS_VERSION)
|
||||
|
||||
$(GOPLS_VERSION_DIR): gopls-install
|
||||
|
||||
# Run gopls
|
||||
gopls-run: $(GOPLS_VERSION_DIR)
|
||||
$(GOPLS_VERSION_DIR)/gopls check $(SOURCES) 2>&1 >$(GOPLS_TEMP_FILE)
|
||||
@if [[ $$(wc -l < $(GOPLS_TEMP_FILE)) -ne 0 ]]; then \
|
||||
cat $(GOPLS_TEMP_FILE); \
|
||||
exit 1; \
|
||||
fi
|
||||
rm $(GOPLS_TEMP_FILE)
|
|
@ -23,8 +23,3 @@ $(LINT_DIR):
|
|||
# Run linters
|
||||
lint: $(LINT_DIR)
|
||||
$(LINT_DIR)/golangci-lint run
|
||||
|
||||
# Run gofumpt
|
||||
fumpt:
|
||||
@echo "⇒ Processing gofumpt check"
|
||||
@gofumpt -l -w cmd/ pkg/ misc/
|
18
mk/staticcheck.mk
Normal file
18
mk/staticcheck.mk
Normal file
|
@ -0,0 +1,18 @@
|
|||
BIN ?= bin
|
||||
STATICCHECK_VERSION ?= 2024.1.1
|
||||
STATICCHECK_DIR ?= $(abspath $(BIN))/staticcheck
|
||||
STATICCHECK_VERSION_DIR ?= $(STATICCHECK_DIR)/$(STATICCHECK_VERSION)
|
||||
|
||||
.PHONY: staticcheck-install staticcheck-run
|
||||
|
||||
# Install staticcheck
|
||||
staticcheck-install:
|
||||
@rm -rf $(STATICCHECK_DIR)
|
||||
@mkdir $(STATICCHECK_DIR)
|
||||
@GOBIN=$(STATICCHECK_VERSION_DIR) go install honnef.co/go/tools/cmd/staticcheck@$(STATICCHECK_VERSION)
|
||||
|
||||
$(STATICCHECK_VERSION_DIR): staticcheck-install
|
||||
|
||||
# Run staticcheck
|
||||
staticcheck-run: $(STATICCHECK_VERSION_DIR)
|
||||
@$(STATICCHECK_VERSION_DIR)/staticcheck ./...
|
Loading…
Reference in a new issue