mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-31 21:13:49 +08:00
refactor: use WaitGroup.Go to simplify code (#16539)
### Summary Adopt sync.WaitGroup.Go (Go 1.25) to simplify tracked goroutine spawning. This replaces the error-prone trio of wg.Add(1), go func(), and defer wg.Done() with a single, self-contained call. More info: https://github.com/golang/go/issues/63796 Signed-off-by: grandpig <grandpig@outlook.com>
This commit is contained in:
@@ -212,9 +212,7 @@ func NewVariableWatcher(store VariableStore) *VariableWatcher {
|
||||
|
||||
// Start starts watching for variable changes
|
||||
func (w *VariableWatcher) Start(interval time.Duration) {
|
||||
w.wg.Add(1)
|
||||
go func() {
|
||||
defer w.wg.Done()
|
||||
w.wg.Go(func() {
|
||||
ticker := time.NewTicker(interval)
|
||||
defer ticker.Stop()
|
||||
|
||||
@@ -228,7 +226,7 @@ func (w *VariableWatcher) Start(interval time.Duration) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
})
|
||||
common.Info("Variable watcher started", zap.Duration("interval", interval))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user