mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Initialize git repository - Add comprehensive .gitignore for Go projects - Install golangci-lint v2.6.0 (latest v2) globally - Configure .golangci.yml with appropriate linters and formatters - Fix all formatting issues (gofmt) - Fix all errcheck issues (unchecked errors) - Adjust complexity threshold for validation functions - All checks passing: build, test, vet, lint
91 lines
2.2 KiB
Makefile
91 lines
2.2 KiB
Makefile
.PHONY: build test clean lint fmt vet install-deps help
|
|
|
|
# Go parameters
|
|
GOCMD=go
|
|
GOBUILD=$(GOCMD) build
|
|
GOCLEAN=$(GOCMD) clean
|
|
GOTEST=$(GOCMD) test
|
|
GOGET=$(GOCMD) get
|
|
GOMOD=$(GOCMD) mod
|
|
BINARY_NAME=models
|
|
BINARY_UNIX=$(BINARY_NAME)_unix
|
|
|
|
# Build the project
|
|
build:
|
|
$(GOBUILD) -o bin/$(BINARY_NAME) -v ./cmd
|
|
|
|
# Run tests
|
|
test:
|
|
$(GOTEST) -v ./...
|
|
|
|
# Run tests with coverage
|
|
test-coverage:
|
|
$(GOTEST) -race -coverprofile=coverage.out -covermode=atomic ./...
|
|
$(GOCMD) tool cover -html=coverage.out -o coverage.html
|
|
|
|
# Clean build files
|
|
clean:
|
|
$(GOCLEAN)
|
|
rm -f bin/$(BINARY_NAME)
|
|
rm -f bin/$(BINARY_NAME)_unix
|
|
rm -f coverage.out coverage.html
|
|
|
|
# Run go fmt
|
|
fmt:
|
|
$(GOCMD) fmt ./...
|
|
|
|
# Run go vet
|
|
vet:
|
|
$(GOCMD) vet ./...
|
|
|
|
# Run linting (requires golangci-lint)
|
|
lint:
|
|
golangci-lint run
|
|
|
|
# Install dependencies
|
|
install-deps:
|
|
$(GOMOD) download
|
|
$(GOMOD) tidy
|
|
|
|
# Install golangci-lint (if not already installed)
|
|
install-lint:
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.55.2
|
|
|
|
# Run all checks (fmt, vet, lint, test)
|
|
check: fmt vet test
|
|
|
|
# Build for Linux
|
|
build-linux:
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o bin/$(BINARY_UNIX) -v ./cmd
|
|
|
|
# Run the application
|
|
run:
|
|
$(GOCMD) run ./cmd
|
|
|
|
# Run with example params
|
|
run-example:
|
|
./bin/$(BINARY_NAME) summary params.yaml
|
|
|
|
# Generate mocks (requires mockery)
|
|
mocks:
|
|
@echo "Generating mocks..."
|
|
@which mockery > /dev/null || (echo "Install mockery: go install github.com/vektra/mockery/v2@latest" && exit 1)
|
|
mockery --all --output ./mocks
|
|
|
|
# Help
|
|
help:
|
|
@echo "Available commands:"
|
|
@echo " build - Build the project"
|
|
@echo " test - Run tests"
|
|
@echo " test-coverage - Run tests with coverage"
|
|
@echo " clean - Clean build files"
|
|
@echo " fmt - Format code"
|
|
@echo " vet - Run go vet"
|
|
@echo " lint - Run linter"
|
|
@echo " check - Run fmt, vet, and test"
|
|
@echo " install-deps - Install dependencies"
|
|
@echo " install-lint - Install golangci-lint"
|
|
@echo " run - Run the application"
|
|
@echo " run-example - Run with example parameters"
|
|
@echo " mocks - Generate mocks"
|