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)) } } }