Skip to content

x/tools/internal/inline: remove dependency on the Go command #71406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
findleyr opened this issue Jan 23, 2025 · 2 comments
Closed

x/tools/internal/inline: remove dependency on the Go command #71406

findleyr opened this issue Jan 23, 2025 · 2 comments
Assignees
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Member

The x/tools source code inliner invokes the Go command indirectly, when it runs goimports logic to compute import edits:
https://cs.opensource.google/go/x/tools/+/master:internal/refactor/inline/inline.go;l=403;drc=39017333097c18f58aa50f00bcd4ce01983ea305

Since the inliner is used in the analysis framework, this is really a violation of boundaries, and causes practical problems when analysis drivers do not have access to the go command for the current environment.

There's also no good reason for this dependency, except that the way goimports is currently factored couples the resolution of imports with the computation of fixes. CC @pjweinb who has also run into this problem while wiring in the modcache index to goimports.

In the short term, we need to remove this dependency from the inliner--even if it means duplicating some logic from goimports.

CC @adonovan @lfolger

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jan 23, 2025
@gopherbot gopherbot added this to the Unreleased milestone Jan 23, 2025
@adonovan
Copy link
Member

Related:

If analyzers can rely on -fix to remove unused imports, this task becomes trivial.

@adonovan
Copy link
Member

Fixed by @jba in https://go.dev/cl/661635.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants