You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wormhole-client/Makefile

80 lines
2.2 KiB

GO = go
APP_NAME = wormhole-client
VERSION = v1.0.0
LDFLAGS = -ldflags "-X main.version=$(VERSION) -X main.buildTime=$(shell date -u '+%Y-%m-%d_%H:%M:%S')"
.PHONY: all build clean deps test run install uninstall lint coverage fmt vet check
all: clean deps build
deps:
$(GO) mod download
$(GO) mod tidy
build:
$(GO) build $(LDFLAGS) -o bin/$(APP_NAME) cmd/wormhole-client/main.go
# 格式化代码
fmt:
$(GO) fmt ./...
# 静态分析
vet:
$(GO) vet ./...
# 代码检查 (需要安装 golangci-lint)
lint:
@which golangci-lint > /dev/null || (echo "Installing golangci-lint..." && go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest)
golangci-lint run
# 运行测试并生成覆盖率报告
coverage:
$(GO) test -v -race -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# 完整的代码检查
check: fmt vet lint test
run-http: build
./bin/$(APP_NAME) -config configs/client.yaml -mode http
run-global: build
sudo ./bin/$(APP_NAME) -config configs/client.yaml -mode global
run-transparent: build
sudo ./bin/$(APP_NAME) -config configs/client.yaml -mode transparent
test:
$(GO) test -v ./...
clean:
rm -rf bin/ coverage.out coverage.html
install: build
sudo cp bin/$(APP_NAME) /usr/local/bin/
uninstall:
sudo rm -f /usr/local/bin/$(APP_NAME)
help:
@echo "Available targets:"
@echo " build - Build the client binary"
@echo " fmt - Format Go code"
@echo " vet - Run Go vet"
@echo " lint - Run golangci-lint"
@echo " test - Run tests"
@echo " coverage - Run tests with coverage report"
@echo " check - Run all code quality checks"
@echo " run-http - Run HTTP proxy mode"
@echo " run-global - Run global proxy mode (needs sudo)"
@echo " run-transparent - Run transparent proxy mode (needs sudo)"
@echo " clean - Clean build artifacts"
@echo " deps - Download dependencies"
@echo " install - Install to /usr/local/bin"
@echo " uninstall - Remove from /usr/local/bin"
@echo ""
@echo "GUI Access:"
@echo " After starting, access the web GUI at:"
@echo " http://127.0.0.1:8080/gui"