Skip to content

Commit 19d3abc

Browse files
committed
mod/modpkgload: Make LoadPackages support nil shouldIncludePkgFile
The docs already state: // The shouldIncludePkgFile function is used to determine whether a // given file in a package should be considered to be part of the build. // If it returns true for a package, the file's imports will be followed. // A nil value corresponds to a function that always returns true. However the implementation didn't match this, and instead crashed if `shouldIncludePkgFile` is nil. Now fixed. Change-Id: I5610a38335625b0a74363a00cf8b001f550f608e Signed-off-by: Matthew Sackman <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1217675 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Roger Peppe <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 12ec0ec commit 19d3abc

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

internal/mod/modpkgload/pkgload.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ func LoadPackages(
182182
rootPkgPaths []string,
183183
shouldIncludePkgFile func(pkgPath string, mod module.Version, fsys fs.FS, mf modimports.ModuleFile) bool,
184184
) *Packages {
185+
if shouldIncludePkgFile == nil {
186+
shouldIncludePkgFile = func(pkgPath string, mod module.Version, fsys fs.FS, mf modimports.ModuleFile) bool { return true }
187+
}
185188
pkgs := &Packages{
186189
mainModuleVersion: module.MustNewVersion(mainModulePath, ""),
187190
mainModuleLoc: mainModuleLoc,

0 commit comments

Comments
 (0)