feat(go): Replace hardcoded stdlib set with GoImportResolver struct (PR-09)#557
Merged
shivasurya merged 1 commit intomainfrom Feb 25, 2026
Merged
feat(go): Replace hardcoded stdlib set with GoImportResolver struct (PR-09)#557shivasurya merged 1 commit intomainfrom
shivasurya merged 1 commit intomainfrom
Conversation
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #557 +/- ##
==========================================
- Coverage 83.36% 83.32% -0.04%
==========================================
Files 143 143
Lines 17820 17782 -38
==========================================
- Hits 14855 14817 -38
Misses 2426 2426
Partials 539 539 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced Feb 25, 2026
Owner
Author
This was referenced Feb 25, 2026
Owner
Author
Merge activity
|
0c91e04 to
8ea75ed
Compare
5b74685 to
e50cbf2
Compare
…PR-09) Replaced the hardcoded `goStdlibSet()` function with a dynamic `GoImportResolver` struct that uses `StdlibLoader.ValidateStdlibImport()` for version-aware stdlib detection, with a heuristic fallback (no domain separator in path) when no loader is available. Added `ImportType` enum (ImportStdlib, ImportThirdParty, ImportLocal) and `ClassifyImport`/`ResolveImports` methods. Updated tests: removed `TestGoStdlibSet` and hardcoded `StdlibPackages` assertions, added 10 new `TestGoImportResolver_*` tests covering nil registry, fallback heuristic, loader delegation, and full import classification. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
8ea75ed to
899ef90
Compare
Code Pathfinder Security ScanNo security issues detected.
Powered by Code Pathfinder |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
goStdlibSet()hardcoded map with a dynamicGoImportResolverstruct that usesStdlibLoader.ValidateStdlibImport()for version-aware, registry-backed stdlib detectionImportTypeenum (ImportUnknown,ImportStdlib,ImportThirdParty,ImportLocal) and public methodsClassifyImport/ResolveImportsfor structured import classificationisStdlibImportFallback) for cases where noStdlibLoaderis available — packages with no domain separator (.) in their path and not prefixed withinternal/are classified as stdlibStdlibPackagesassertions fromTestBuildGoModuleRegistryand deletedTestGoStdlibSet; added 10 newTestGoImportResolver_*tests covering nil registry, fallback heuristic, loader delegation, local module detection, relative paths, and batch resolutionChanges
sast-engine/graph/callgraph/resolution/go_imports.gogoStdlibSet()function (~124 lines of hardcoded map)registry.StdlibPackages = goStdlibSet()call fromBuildGoModuleRegistryImportTypeenum with four constantsGoImportResolverstruct withNewGoImportResolverconstructorisStdlibImport,isStdlibImportFallback,ClassifyImport,ResolveImportsmethodssast-engine/graph/callgraph/resolution/go_imports_test.goTestGoStdlibSettestStdlibPackagesassertions fromTestBuildGoModuleRegistrymockResolutionStdlibLoaderin-package mock implementingStdlibLoaderInterfaceTestGoImportResolver_NilRegistry,TestGoImportResolver_isStdlibImportFallback,TestGoImportResolver_isStdlibImport_WithLoader,TestGoImportResolver_isStdlibImport_NilLoader_FallsBackToHeuristic,TestGoImportResolver_ClassifyImport_Stdlib,TestGoImportResolver_ClassifyImport_ThirdParty,TestGoImportResolver_ClassifyImport_Local_RelativePath,TestGoImportResolver_ClassifyImport_Local_SameModule,TestGoImportResolver_ResolveImports,TestGoImportResolver_ResolveImports_EmptyTest plan
TestGoImportResolver_*tests passTestBuildGoModuleRegistrystill passesTestExtractGoImportsstill passes (uses emptyStdlibPackagesmap)🤖 Generated with Claude Code