From 1aa63c531aa5c5d587185f219adaf5d91acd25a5 Mon Sep 17 00:00:00 2001 From: Alexey Date: Sun, 23 Nov 2025 11:03:41 +0200 Subject: [PATCH] add Makefile --- Makefile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ac5762a --- /dev/null +++ b/Makefile @@ -0,0 +1,45 @@ +# Makefile + +NAME = tsctl +ENTRY = ./cmd/$(NAME)/main.go +BIN_DIR = bin +BINARY = ${BIN_DIR}/$(NAME) +CHECK_LINTER = command -v golangci-lint >/dev/null 2>&1 +CHECK_IMPORTS = command -v goimports >/dev/null 2>&1 +PATH := $(PATH):$(HOME)/go/bin + +lint-tools: + @if ! $(CHECK_LINTER); then \ + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ + GOLANGCI_LINT_VERSION=v1.62.2 sh -s -- -b $$HOME/go/bin; \ + fi + +imports-tools: + @if ! $(CHECK_IMPORTS); then \ + go install golang.org/x/tools/cmd/goimports@latest; \ + fi + +.PHONY: all build run test lint fmt imports + +all: build + +run: build + @echo "-- running $(NAME)" + @$(BINARY) + +build: + @echo "-- building $(NAME)" + @go build -o $(BINARY) $(ENTRY) + +test: + @echo "-- testing $(NAME)" + @go test ./... -count=1 -v + +lint: lint-tools + @golangci-lint run ./... + +fmt: + @go fmt ./... + +imports: imports-tools + @goimports -w . \ No newline at end of file