Skip to content

Get dependencies and their Go versions via "go list" - #45

Merged
bobg merged 11 commits into
mainfrom
bobg/golist-deps
Nov 18, 2026
Merged

bobg merged 11 commits into
mainfrom
bobg/golist-deps

Conversation

@bobg

@bobg bobg commented Nov 16, 2026

Copy link
Copy Markdown
Owner

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.

Fixes #43.

@coveralls

coveralls commented Nov 16, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 44336056890

Coverage increased (+1.9%) to 71.718%

Details

  • Coverage increased (+1.9%) from the base build.
  • Patch coverage: 19 uncovered changes across 3 files (69 of 88 lines covered, 78.41%).
  • 3 coverage regressions across 2 files.

Uncovered Changes

File Changed Covered %
cmd/mingo/main.go 10 0 0.0%
deps.go 64 57 89.06%
scan.go 14 12 85.71%

Coverage Regressions

3 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
scan.go 2 69.88%
cmd/mingo/main.go 1 0.0%

Coverage Stats

Coverage Status
Relevant Lines: 1234
Covered Lines: 885
Line Coverage: 71.72%
Coverage Strength: 0.72 hits per line

💛 - Coveralls

@bobg
bobg marked this pull request as ready for review November 16, 2026 19:06
@bobg
bobg requested a balanced review from Copilot November 16, 2026 19:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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.

2 open issues
What changed in this PR

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.

Review effort: Balanced

Comment thread deps.go Resolved
Comment thread scan.go Resolved
@bobg
bobg requested a review from logica0419 November 17, 2026 00:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Dependency reloading drops caller-supplied build flags, which can omit tagged imports and cause the computed minimum Go version to be too low.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Dependency resolution ignores caller-supplied build flags

scan.go:132

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.

2 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity 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.

Review effort: Balanced

Comment thread scan.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@github-actions

Copy link
Copy Markdown

Modver result

This report was generated by Modver,
a Go package and command that helps you obey semantic versioning rules in your Go module.

This PR requires (at least) an increase in your module's minor version number.

checking Scanner
  struct field BuildFlags was added to github.com/bobg/mingo.Scanner
    Minor

@bobg
bobg merged commit 9dcc292 into main Nov 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scanDeps ignores replace directives

3 participants