Skip to content

Commit

Permalink
logcheck: support new golangci-lint plugin interface
Browse files Browse the repository at this point in the history
The new plugin interface was added in golangci/golangci-lint#3887
to allow settings for custom plugins. This commit implements the new
plugin interface with find `config` value in the settings, and passes it
to flag `--config`.
  • Loading branch information
linxiulei committed Jul 30, 2023
1 parent 37c27f0 commit b73fed7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
@@ -1,4 +1,4 @@
module sigs.k8s.io/logtools
module github.com/linxiulei/logtools

go 1.15

Expand Down
14 changes: 14 additions & 0 deletions logcheck/plugin/plugin.go
Expand Up @@ -33,3 +33,17 @@ func (*analyzerPlugin) GetAnalyzers() []*analysis.Analyzer {

// AnalyzerPlugin is the entry point for golangci-lint.
var AnalyzerPlugin analyzerPlugin

// New is the enry point for golangci-lint, which takes priority over AnalyzerPlugin.
func New(conf any) []*analysis.Analyzer {
a := pkg.Analyser()
conf, ok := conf.(map[string]any)
if !ok {
return []*analysis.Analyzer{a}
}

if config, ok := conf["config"]; ok {
a.Flags.Set("config", config)
}
return []*analysis.Analyzer{a}
}

0 comments on commit b73fed7

Please sign in to comment.