From 6a2ecce25a0766c3785e3d3546248bba84d73e0b Mon Sep 17 00:00:00 2001 From: vvakame Date: Mon, 7 Sep 2020 14:58:59 +0900 Subject: [PATCH] add plugin for golangci-lint --- passes/unclosetx/plugin/main.go | 22 ++++++++++++++++++++++ passes/unstopiter/plugin/main.go | 22 ++++++++++++++++++++++ passes/wraperr/plugin/main.go | 22 ++++++++++++++++++++++ plugin/main.go | 26 ++++++++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 passes/unclosetx/plugin/main.go create mode 100644 passes/unstopiter/plugin/main.go create mode 100644 passes/wraperr/plugin/main.go create mode 100644 plugin/main.go diff --git a/passes/unclosetx/plugin/main.go b/passes/unclosetx/plugin/main.go new file mode 100644 index 0000000..5805b4c --- /dev/null +++ b/passes/unclosetx/plugin/main.go @@ -0,0 +1,22 @@ +// This file can build as a plugin for golangci-lint by below command. +// go build -buildmode=plugin -o unclosetx.so github.com/gcpug/zagane/passes/unclosetx/plugin +// See: https://golangci-lint.run/contributing/new-linters/#how-to-add-a-private-linter-to-golangci-lint + +package main + +import ( + "github.com/gcpug/zagane/passes/unclosetx" + "golang.org/x/tools/go/analysis" +) + +// AnalyzerPlugin provides analyzers as a plugin. +// It follows golangci-lint style plugin. +var AnalyzerPlugin analyzerPlugin + +type analyzerPlugin struct{} + +func (analyzerPlugin) GetAnalyzers() []*analysis.Analyzer { + return []*analysis.Analyzer{ + unclosetx.Analyzer, + } +} diff --git a/passes/unstopiter/plugin/main.go b/passes/unstopiter/plugin/main.go new file mode 100644 index 0000000..caa4190 --- /dev/null +++ b/passes/unstopiter/plugin/main.go @@ -0,0 +1,22 @@ +// This file can build as a plugin for golangci-lint by below command. +// go build -buildmode=plugin -o unstopiter.so github.com/gcpug/zagane/passes/unstopiter/plugin +// See: https://golangci-lint.run/contributing/new-linters/#how-to-add-a-private-linter-to-golangci-lint + +package main + +import ( + "github.com/gcpug/zagane/passes/unstopiter" + "golang.org/x/tools/go/analysis" +) + +// AnalyzerPlugin provides analyzers as a plugin. +// It follows golangci-lint style plugin. +var AnalyzerPlugin analyzerPlugin + +type analyzerPlugin struct{} + +func (analyzerPlugin) GetAnalyzers() []*analysis.Analyzer { + return []*analysis.Analyzer{ + unstopiter.Analyzer, + } +} diff --git a/passes/wraperr/plugin/main.go b/passes/wraperr/plugin/main.go new file mode 100644 index 0000000..5afdefd --- /dev/null +++ b/passes/wraperr/plugin/main.go @@ -0,0 +1,22 @@ +// This file can build as a plugin for golangci-lint by below command. +// go build -buildmode=plugin -o wraperr.so github.com/gcpug/zagane/passes/wraperr/plugin +// See: https://golangci-lint.run/contributing/new-linters/#how-to-add-a-private-linter-to-golangci-lint + +package main + +import ( + "github.com/gcpug/zagane/passes/wraperr" + "golang.org/x/tools/go/analysis" +) + +// AnalyzerPlugin provides analyzers as a plugin. +// It follows golangci-lint style plugin. +var AnalyzerPlugin analyzerPlugin + +type analyzerPlugin struct{} + +func (analyzerPlugin) GetAnalyzers() []*analysis.Analyzer { + return []*analysis.Analyzer{ + wraperr.Analyzer, + } +} diff --git a/plugin/main.go b/plugin/main.go new file mode 100644 index 0000000..a9535d4 --- /dev/null +++ b/plugin/main.go @@ -0,0 +1,26 @@ +// This file can build as a plugin for golangci-lint by below command. +// go build -buildmode=plugin -o zagane.so github.com/gcpug/zagane/plugin +// See: https://golangci-lint.run/contributing/new-linters/#how-to-add-a-private-linter-to-golangci-lint + +package main + +import ( + "github.com/gcpug/zagane/passes/unclosetx" + "github.com/gcpug/zagane/passes/unstopiter" + "github.com/gcpug/zagane/passes/wraperr" + "golang.org/x/tools/go/analysis" +) + +// AnalyzerPlugin provides analyzers as a plugin. +// It follows golangci-lint style plugin. +var AnalyzerPlugin analyzerPlugin + +type analyzerPlugin struct{} + +func (analyzerPlugin) GetAnalyzers() []*analysis.Analyzer { + return []*analysis.Analyzer{ + unstopiter.Analyzer, + unclosetx.Analyzer, + wraperr.Analyzer, + } +}