diff options
| -rw-r--r-- | internal/frontend/search.go | 6 | ||||
| -rw-r--r-- | internal/symbol/generate.go | 6 | ||||
| -rw-r--r-- | internal/worker/fetch.go | 18 |
3 files changed, 10 insertions, 20 deletions
diff --git a/internal/frontend/search.go b/internal/frontend/search.go index 0dac8417..842d505a 100644 --- a/internal/frontend/search.go +++ b/internal/frontend/search.go @@ -580,11 +580,9 @@ func addVulns(ctx context.Context, rs []*SearchResult, vc *vuln.Client) { var wg sync.WaitGroup // TODO(golang/go#48223): throttle concurrency? for _, r := range rs { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { r.Vulns = vuln.VulnsForPackage(ctx, r.ModulePath, r.Version, r.PackagePath, vc) - }() + }) } wg.Wait() diff --git a/internal/symbol/generate.go b/internal/symbol/generate.go index 3cb8f569..1fb5b600 100644 --- a/internal/symbol/generate.go +++ b/internal/symbol/generate.go @@ -42,11 +42,9 @@ func GenerateFeatureContexts(ctx context.Context, pkgPath, pkgDir string) (map[s var wg sync.WaitGroup walkers := make([]*Walker, len(internal.BuildContexts)) for i, context := range contexts { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { walkers[i] = NewWalker(context, pkgPath, pkgDir, filepath.Join(build.Default.GOROOT, "src")) - }() + }) } wg.Wait() var featureCtx = make(map[string]map[string]bool) // feature -> context name -> true diff --git a/internal/worker/fetch.go b/internal/worker/fetch.go index a063ef9a..f9b741e1 100644 --- a/internal/worker/fetch.go +++ b/internal/worker/fetch.go @@ -321,9 +321,7 @@ func (f *Fetcher) fetchAndInsertModule(ctx context.Context, modulePath, requeste // target if applicable. done := internal.RequestState(ctx, "fetching") var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { start := time.Now() fr := fetch.FetchModule(ctx, modulePath, requestedVersion, moduleGetter) if fr == nil { @@ -331,24 +329,20 @@ func (f *Fetcher) fetchAndInsertModule(ctx context.Context, modulePath, requeste } ft.FetchResult = *fr ft.timings["fetch.FetchModule"] = time.Since(start) - }() + }) // Do not resolve the @main and @master version if proxy fetch is disabled. var main string - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { if !f.ProxyClient.FetchDisabled() { main = resolvedVersion(ctx, modulePath, internal.MainVersion, moduleGetter) } - }() + }) var master string - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { if !f.ProxyClient.FetchDisabled() { master = resolvedVersion(ctx, modulePath, internal.MasterVersion, moduleGetter) } - }() + }) wg.Wait() done() ft.MainVersion = main |
