-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
golangci-lint custom follows plugin's go.mod replace directives #6098
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
Conversation
bacbcb4
to
a0a5cf4
Compare
You don't need that. You only need to use Or to follow the "manual way": https://golangci-lint.run/docs/plugins/module-plugins/#the-manual-way |
Thanks for the review, @ldez! You're right that a For example.
I've thought the root cause is the temporary If there's an existing "as-is" automatic way that makes custom adopt the plugin's |
A plugin must contain the Analyzer so I don't understand what your plugin is. During development, you don't need |
You are write. It could be solved with both plugins:
- module: example.com/myanalyzer
import: example.com/myanalyzer/myplugin
path: . When the repository looks like:
Thanks for your advice! |
A plugin should not depend on golangci-lint, but on the See the example: https://github.com/golangci/example-plugin-module-linter |
When developing a golangci-lint plugin, it’s common to first implement the analyzer using the go/analysis interface and then wrap it with the golangci-lint plugin interface in a separate module. This separation is useful because the go/analysis interface is a generic abstraction that can be reused outside golangci-lint.
During development, a plugin may depend on an unreleased analyzer implementation and declare a replace directive in its
go.mod
. However, the currentgolangci-lint custom
command ignores these directives. As a result, the custom build only succeeds if the plugin and the analyzer are bundled within the samego.mod
.This PR copies
replace
directives from the plugin'sgo.mod
into the temporarygo.mod
used bygolangci-lint custom
. This ensures that the custom build correctly recognizes both the plugin and any modules it references viareplace
. As a result, plugins and analyzers can now be managed as separate modules.