go-mongo/makefile
2025-05-31 18:38:18 +03:00

51 lines
811 B
Makefile

SHELL := /bin/bash
.DEFAULT_GOAL := build
TARGET := bin/app
VERSION := 1.0.0
BUILD := $(shell git rev-parse HEAD 2>/dev/null || echo "dev")
LDFLAGS := "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)"
GOFLAGS := -ldflags="$(LDFLAGS)"
SRC := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
hello:
@echo "Target: $(TARGET)"
@echo "Go Flags: $(GOFLAGS)"
build: | bin
@go build $(GOFLAGS) -o $(TARGET) .
bin:
@mkdir -p bin
run: build
@./$(TARGET)
dev:
@CompileDaemon \
-directory="." \
-exclude-dir="vendor" \
-exclude="\.tmp$$" \
-exclude="\.log$$" \
-exclude="\.pid$$" \
-build='go build -o $(TARGET)' \
-command='./$(TARGET)'
start: build
@./$(TARGET)
clean:
@rm -rf bin tmp
format:
@gofmt -l -w $(SRC)
simplify:
@gofmt -s -l -w $(SRC)
test:
@go test ./...