Skip to content

Commit

Permalink
remove extra call to packages.Load fix #2505
Browse files Browse the repository at this point in the history
  • Loading branch information
vikstrous committed Jan 23, 2023
1 parent 43c9a1d commit 098f337
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions internal/code/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ func (p *Packages) ReloadAll(importPaths ...string) []*packages.Package {
return p.LoadAll(importPaths...)
}

func (p *Packages) checkModuleLoaded(pkgs []*packages.Package) bool {
for i := range pkgs {
if pkgs[i] == nil || pkgs[i].Module == nil {
return false
}
}
return true
}

// LoadAll will call packages.Load and return the package data for the given packages,
// but if the package already have been loaded it will return cached values instead.
func (p *Packages) LoadAll(importPaths ...string) []*packages.Package {
Expand All @@ -65,13 +56,6 @@ func (p *Packages) LoadAll(importPaths ...string) []*packages.Package {
if len(missing) > 0 {
p.numLoadCalls++
pkgs, err := packages.Load(&packages.Config{Mode: mode}, missing...)

// Sometimes packages.Load not loaded the module info. Call it again to reload it.
if !p.checkModuleLoaded(pkgs) {
fmt.Println("reloading module info")
pkgs, err = packages.Load(&packages.Config{Mode: mode}, missing...)
}

if err != nil {
p.loadErrors = append(p.loadErrors, err)
}
Expand Down

0 comments on commit 098f337

Please sign in to comment.