diff --git a/main.go b/main.go index d617315..8824adb 100644 --- a/main.go +++ b/main.go @@ -299,7 +299,6 @@ func StartLooking(ctx context.Context, lookingPath string) { g.SetLimit(config.APPConfig.HandleFileCount) // 设置最大同时处理文件数为50 // 执行所有任务 for _, task := range tasks { - task := task // 创建局部变量 g.Go(func() error { select { case <-ctx.Done(): @@ -333,7 +332,6 @@ func StartLooking(ctx context.Context, lookingPath string) { AddLog("上传程序已退出") return case <-t.C: - f() } } } @@ -376,10 +374,10 @@ func processFile(ctx context.Context, filePath string, fileLines int) { // 创建10个worker处理文件上传 for i := 0; i < config.APPConfig.ThreadCount; i++ { wg.Add(1) - go func(workerID int) { - processLines(ctx, lines, workerID, filePath) + go func() { + processLines(ctx, lines, i, filePath) wg.Done() - }(i) + }() } // 读取文件并发送到通道