add Makefile
This commit is contained in:
45
Makefile
Normal file
45
Makefile
Normal file
@@ -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 .
|
||||
Reference in New Issue
Block a user