Help us shape the future of Go! Take the 2026 Go Developer Survey

sdk

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package plugin/sdk provides helper types and functions for building ScrapeGoat plugins using the init() registration pattern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasePlugin

type BasePlugin struct {
	PluginName    string
	PluginType    string
	PluginVersion string
	Config        map[string]any
	Logger        *slog.Logger
}

BasePlugin provides a default implementation for the Plugin interface that plugin authors can embed to reduce boilerplate.

func (*BasePlugin) Close

func (p *BasePlugin) Close() error

Close is a no-op by default.

func (*BasePlugin) GetBool

func (p *BasePlugin) GetBool(key string, defaultVal bool) bool

GetBool extracts a boolean config value with a default.

func (*BasePlugin) GetInt

func (p *BasePlugin) GetInt(key string, defaultVal int) int

GetInt extracts an integer config value with a default.

func (*BasePlugin) GetString

func (p *BasePlugin) GetString(key, defaultVal string) string

GetString extracts a string config value with a default.

func (*BasePlugin) Init

func (p *BasePlugin) Init(cfg map[string]any) error

Init stores config and is a no-op by default.

func (*BasePlugin) Name

func (p *BasePlugin) Name() string

Name returns the plugin name.

func (*BasePlugin) Version

func (p *BasePlugin) Version() string

Version returns the plugin version.

type FilterMiddleware

type FilterMiddleware struct {
	FilterFn   ItemFilter
	PluginName string
}

FilterMiddleware creates a pipeline middleware from a filter function.

func (*FilterMiddleware) Name

func (m *FilterMiddleware) Name() string

Name returns the middleware name.

func (*FilterMiddleware) Process

func (m *FilterMiddleware) Process(item *types.Item) (*types.Item, error)

Process applies the filter.

type ItemFilter

type ItemFilter func(item *types.Item) bool

ItemFilter is a function that returns true to keep an item.

type ItemTransform

type ItemTransform func(item *types.Item)

ItemTransform is a function that modifies an item in place.

type TransformMiddleware

type TransformMiddleware struct {
	TransformFn ItemTransform
	PluginName  string
}

TransformMiddleware creates a pipeline middleware from a transform function.

func (*TransformMiddleware) Name

func (m *TransformMiddleware) Name() string

Name returns the middleware name.

func (*TransformMiddleware) Process

func (m *TransformMiddleware) Process(item *types.Item) (*types.Item, error)

Process applies the transform.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL