# Makefile NAME = tsctl ENTRY = ./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 VERSION = 0.0.1-dev 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 swag build run test lint fmt imports all: build run: build @echo "-- running $(NAME)" @$(BINARY) BUILD_PARAMS = -trimpath -ldflags "-X git.oblat.lv/alex/triggerssmith/internal/vars.Version=$(VERSION)" build-with-swag: swag build swag: @echo "-- generating swagger docs" @swag init -g cmd/serve.go build: @echo "-- building $(NAME)" @go build $(BUILD_PARAMS) -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 .