From 7b4377ad9d8a7205416df8d6217ef2b010f89481 Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Wed, 22 Jan 2025 16:07:17 +0100 Subject: vendor: delete --- .../plugin-module-register/register/register.go | 73 ---------------------- 1 file changed, 73 deletions(-) delete mode 100644 vendor/github.com/golangci/plugin-module-register/register/register.go (limited to 'vendor/github.com/golangci/plugin-module-register/register') diff --git a/vendor/github.com/golangci/plugin-module-register/register/register.go b/vendor/github.com/golangci/plugin-module-register/register/register.go deleted file mode 100644 index 72ad7f46f..000000000 --- a/vendor/github.com/golangci/plugin-module-register/register/register.go +++ /dev/null @@ -1,73 +0,0 @@ -package register - -import ( - "bytes" - "encoding/json" - "fmt" - "sync" - - "golang.org/x/tools/go/analysis" -) - -// Plugins load mode. -const ( - LoadModeSyntax = "syntax" - LoadModeTypesInfo = "typesinfo" -) - -var ( - pluginsMu sync.RWMutex - plugins = make(map[string]NewPlugin) -) - -// LinterPlugin the interface of the plugin structure. -type LinterPlugin interface { - BuildAnalyzers() ([]*analysis.Analyzer, error) - GetLoadMode() string -} - -// NewPlugin the contract of the constructor of a plugin. -type NewPlugin func(conf any) (LinterPlugin, error) - -// Plugin registers a plugin. -func Plugin(name string, p NewPlugin) { - pluginsMu.Lock() - - plugins[name] = p - - pluginsMu.Unlock() -} - -// GetPlugin gets a plugin by name. -func GetPlugin(name string) (NewPlugin, error) { - pluginsMu.Lock() - defer pluginsMu.Unlock() - - p, ok := plugins[name] - if !ok { - return nil, fmt.Errorf("plugin %q not found", name) - } - - return p, nil -} - -// DecodeSettings decode settings from golangci-lint to the structure of the plugin configuration. -func DecodeSettings[T any](rawSettings any) (T, error) { - var buffer bytes.Buffer - - if err := json.NewEncoder(&buffer).Encode(rawSettings); err != nil { - var zero T - return zero, fmt.Errorf("encoding settings: %w", err) - } - - decoder := json.NewDecoder(&buffer) - decoder.DisallowUnknownFields() - - s := new(T) - if err := decoder.Decode(s); err != nil { - var zero T - return zero, fmt.Errorf("decoding settings: %w", err) - } - - return *s, nil -} -- cgit mrf-deployment