Skip to content

Commit

Permalink
Don't panic on missing pkg.Module
Browse files Browse the repository at this point in the history
  • Loading branch information
podtserkovskiy committed Oct 25, 2024
1 parent 6934633 commit b09bfc6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,10 @@ func normalizePackage(opts *config.IndexOpts, pkg *packages.Package) *packages.P
// We strip that to standardize all the libraries to make sure we are able to jump-to-definition
// of the standard library.
pkg.PkgPath = strings.TrimPrefix(pkg.PkgPath, "std/")
} else {
if pkg.Module == nil {
panic(fmt.Sprintf(
"Should not be possible to have nil module for userland package: %s %s",
pkg,
pkg.PkgPath,
))
}
}

if pkg.Module == nil {
pkg.Module = &packages.Module{}
}

// Follow replaced modules
Expand Down Expand Up @@ -226,6 +221,11 @@ func normalizePackage(opts *config.IndexOpts, pkg *packages.Package) *packages.P
}

if pkg.Module.Path == "" {
log.Errorf(
"Should not be possible to have nil module for userland package: %s %s",
pkg,
pkg.PkgPath,
)
pkg.Module.Path = "."
}

Expand Down

0 comments on commit b09bfc6

Please sign in to comment.