You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Get dependencies and their Go versions via "go list" - #45
This PR changes the dependency-scanning logic to run go list -deps in order to resolve dependencies.
Previously the code was parsing require declarations from go.mod, but this ignored the effects of replace and exclude directives, workspace mode, etc. Running go list allows Go to do its full dependency-resolution process.
This PR supersedes #44 by @logica0419, for whose contributions and patience I'm grateful.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Dependency scanning omits test-only imports and expands beyond the selected package scope, which can underreport the required Go version or fail on unrelated broken packages.
This PR delegates dependency resolution to go list -deps, allowing mingo to use Go’s handling of replacements, exclusions, and workspaces when determining dependency Go-version requirements. It addresses #43 and supersedes #44.
Changes:
Replaces go.mod requirement parsing and per-module downloads with go list JSON processing.
Adds replacement and workspace integration tests, plus dependency error cases.
Updates module requirements and checksums.
File
Description
scan.go
Passes the module directory to dependency scanning.
go.sum
Adds dependency checksums.
go.mod
Updates indirect requirements.
errors_test.go
Adapts error tests and covers malformed Go versions.
deps.go
Resolves dependencies through go list and reads their Go requirements.
deps_test.go
Updates mocks and adds replacement and workspace coverage.
ScanPackages accepts packages loaded with caller-supplied build flags, but this second load preserves only their directories. For example, packages loaded with BuildFlags: []string{"-tags=special"} can import a dependency exclusively from a tagged file; this unconfigured go list omits that dependency, so its declared Go requirement is lost and the computed minimum can be too low. Please preserve the caller's loading context for dependency resolution (or obtain dependency metadata from the supplied package graph), and add a tagged-import regression test.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Workspace transitive dependencies are incorrectly treated as direct, and ScanDir ignores build flags when loading source packages, causing failures or missed requirements in tagged files.
Exclude transitives in workspace mode for direct-only scans
deps.go:39
In workspace mode, go list marks workspace modules as Main: true and omits Indirect, even when they are only transitively imported by the scanned module. For a workspace chain main → direct → transitive, this condition therefore includes transitive's Go requirement with Indirect: false (-deps direct), contrary to the documented direct-only behavior. Determine direct dependencies from the selected packages' imports rather than relying solely on Module.Indirect, and add a workspace-chain regression case.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to evaluate dependency rescanning under custom build flags, which can omit dependencies and understate the required Go version.
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
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.
This PR changes the dependency-scanning logic to run
go list -depsin order to resolve dependencies.Previously the code was parsing
requiredeclarations fromgo.mod, but this ignored the effects ofreplaceandexcludedirectives, workspace mode, etc. Runninggo listallows Go to do its full dependency-resolution process.This PR supersedes #44 by @logica0419, for whose contributions and patience I'm grateful.
Fixes #43.