From 2092fae819961ee8b99c52d0e07337d65879a65f Mon Sep 17 00:00:00 2001 From: YGXB_net Date: Fri, 17 Oct 2025 22:03:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=BE=93=E5=87=BA=E4=B8=AD=E7=9A=84=E6=8D=A2=E8=A1=8C?= =?UTF-8?q?=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 185c48d..101dd34 100644 --- a/main.go +++ b/main.go @@ -329,7 +329,7 @@ func StartLooking(ctx context.Context, lookingPath string) { AddLog("所有任务执行完成!") } - AddLog(fmt.Sprintf("上传完成,耗时:%s\n", time.Since(start))) + AddLog(fmt.Sprintf("上传完成,耗时:%s", time.Since(start))) } for { @@ -372,7 +372,7 @@ func processFile(ctx context.Context, filePath string, fileLines int) { // 打开文件 file, err := os.Open(filePath) if err != nil { - AddLog(fmt.Sprintf("无法打开文件 %s: %v\n", filePath, err)) + AddLog(fmt.Sprintf("无法打开文件 %s: %v", filePath, err)) return } defer file.Close() @@ -395,7 +395,7 @@ func processFile(ctx context.Context, filePath string, fileLines int) { lines <- scanner.Text() lineCount++ if lineCount%10000 == 0 { - AddLog(fmt.Sprintf("文件【%s】处理进度:%.2f%%\n", filePath, float64(lineCount)/float64(fileLines)*100)) + AddLog(fmt.Sprintf("文件【%s】处理进度:%.2f%%", filePath, float64(lineCount)/float64(fileLines)*100)) } } @@ -403,11 +403,11 @@ func processFile(ctx context.Context, filePath string, fileLines int) { wg.Wait() if err := scanner.Err(); err != nil { - AddLog(fmt.Sprintf("读取文件 %s 错误: %v\n", filePath, err)) + AddLog(fmt.Sprintf("读取文件 %s 错误: %v", filePath, err)) return } - AddLog(fmt.Sprintf("文件【%s】处理完成,共处理 %d 行数据\n", filePath, lineCount)) + AddLog(fmt.Sprintf("文件【%s】处理完成,共处理 %d 行数据", filePath, lineCount)) } func processLines(ctx context.Context, lines <-chan string, workerID int, filePath string) { @@ -422,7 +422,7 @@ func processLines(ctx context.Context, lines <-chan string, workerID int, filePa } // 上传数据 if err := api.UploadDataToServer(httpClient, line); err != nil { - AddLog(fmt.Sprintf("Worker %d (文件 %s): 上传失败: %v\n", workerID, filePath, err)) + AddLog(fmt.Sprintf("Worker %d (文件 %s): 上传失败: %v", workerID, filePath, err)) } } }