From 7a2b1d7e0315ba7c3fc1a9ac2985ce185a44c276 Mon Sep 17 00:00:00 2001 From: xfy Date: Thu, 9 Apr 2026 17:58:18 +0800 Subject: [PATCH] =?UTF-8?q?chore(makefile):=20=E4=BD=BF=E7=94=A8=20goimpor?= =?UTF-8?q?ts=20=E6=9B=BF=E4=BB=A3=20go=20fmt=20=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit goimports 可同时处理格式化和导入排序。 Co-Authored-By: Claude Opus 4.6 --- Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4d66d01..b78e758 100644 --- a/Makefile +++ b/Makefile @@ -218,10 +218,15 @@ bench-check: # 代码质量 # ============================================ -# 格式化代码 +# 格式化代码(使用 goimports 替代 go fmt) fmt: - @echo "Formatting code..." - go fmt ./... + @echo "Formatting code with goimports..." + @if command -v goimports >/dev/null 2>&1; then \ + goimports -w .; \ + else \ + echo "goimports not installed. Run: go install golang.org/x/tools/cmd/goimports@latest"; \ + exit 1; \ + fi # 静态检查 lint: