From 1f0158dd76a27b733fd3e821ea28435fc08ffff2 Mon Sep 17 00:00:00 2001 From: YGXB_net Date: Sat, 11 Oct 2025 12:26:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor(tool):=20=E4=BC=98=E5=8C=96=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=E5=92=8C=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tool/update-dypid.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tool/update-dypid.go b/tool/update-dypid.go index bcda6d0..b252c34 100644 --- a/tool/update-dypid.go +++ b/tool/update-dypid.go @@ -41,7 +41,7 @@ func main() { files, err := getTxtFiles("./") if err != nil { fmt.Println(err) - return + continue } if files != nil { start := time.Now() @@ -49,23 +49,23 @@ func main() { fileLines := make(map[string]int) fmt.Println("正在统计", len(files), "个文件行数") for _, filePath := range files { - file, err := os.Open(filePath) if err != nil { fmt.Println("打开文件失败:", err) } - defer file.Close() // 使用 bufio.Scanner 逐行读取 scanner := bufio.NewScanner(file) lineCount := 0 for scanner.Scan() { lineCount++ } + file.Close() if lineCount == 0 { - return + continue } fileLines[filepath.Base(filePath)] = lineCount fmt.Println(filepath.Base(filePath), "文件行数:", lineCount) + } var tasks []Task