refactor: 移除冗余的局部变量赋值和函数调用
All checks were successful
构建上传工具 / build-tool (push) Successful in 10m45s
All checks were successful
构建上传工具 / build-tool (push) Successful in 10m45s
This commit is contained in:
8
main.go
8
main.go
@@ -299,7 +299,6 @@ func StartLooking(ctx context.Context, lookingPath string) {
|
|||||||
g.SetLimit(config.APPConfig.HandleFileCount) // 设置最大同时处理文件数为50
|
g.SetLimit(config.APPConfig.HandleFileCount) // 设置最大同时处理文件数为50
|
||||||
// 执行所有任务
|
// 执行所有任务
|
||||||
for _, task := range tasks {
|
for _, task := range tasks {
|
||||||
task := task // 创建局部变量
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
@@ -333,7 +332,6 @@ func StartLooking(ctx context.Context, lookingPath string) {
|
|||||||
AddLog("上传程序已退出")
|
AddLog("上传程序已退出")
|
||||||
return
|
return
|
||||||
case <-t.C:
|
case <-t.C:
|
||||||
f()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,10 +374,10 @@ func processFile(ctx context.Context, filePath string, fileLines int) {
|
|||||||
// 创建10个worker处理文件上传
|
// 创建10个worker处理文件上传
|
||||||
for i := 0; i < config.APPConfig.ThreadCount; i++ {
|
for i := 0; i < config.APPConfig.ThreadCount; i++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(workerID int) {
|
go func() {
|
||||||
processLines(ctx, lines, workerID, filePath)
|
processLines(ctx, lines, i, filePath)
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}(i)
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取文件并发送到通道
|
// 读取文件并发送到通道
|
||||||
|
|||||||
Reference in New Issue
Block a user