-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/imports: merge init and newModuleResolver
Switch the ModuleResolver from a lazy initialization model to a constructor, so that the resolver returned by ProcessEnv.GetResolver is ready to use. A constructor is easier to maintain as it involves less state, avoids redundant calls to init, and avoids bugs where the call to init is missing (such as was the case for the scoreImportPath method). It also lets the caller differentiate between a failure to construct the resolver and a resolver that only returns errors. Pragmatically, I'd like to move toward a model where the caller re-scans imports by asynchronously cloning, priming, and replacing the resolver, rather than blocking. This is a step in that direction. This change is not without risk, but it looks like all calls to ModuleResolver methods are preceded by a call to GetResolver, and errors from GetResolver are handled similarly errors from methods. There is some messiness resulting from this change, particularly in tests. These are noted inline, and can eventually be fixed by similarly avoiding lazy initialization of ProcessEnv. For golang/go#59216 Change-Id: I3b7206417f61a5697ed83e811c177f646afce3b2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/559635 Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
- Loading branch information
Showing
4 changed files
with
114 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.