APP_NAME = netctl SRC = . OUTPUT = ./bin/$(APP_NAME).exe GO = go # 获取 Git commit GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo none) # 获取当前时间 UTC BUILD_TIME := $(shell date -u +%Y-%m-%dT%H:%M:%SZ) .PHONY: build run clean # 编译命令 build: $(GO) build -ldflags "-X 'netcli/cmd.Version=1.0.0' -X 'netcli/cmd.Commit=$(GIT_COMMIT)' -X 'netcli/cmd.BuildTime=$(BUILD_TIME)'" -o $(OUTPUT) $(SRC) # 直接运行 run: $(GO) run -ldflags "-X 'netcli/cmd.Version=1.0.0' -X 'netcli/cmd.Commit=$(GIT_COMMIT)' -X 'netcli/cmd.BuildTime=$(BUILD_TIME)'" $(SRC) # 清理编译文件 clean: rm -f $(OUTPUT)