plugin

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package plugin provides gorisk's plugin loading infrastructure. Plugins are native Go plugins built with "go build -buildmode=plugin". Each plugin .so file must export one or both of:

  • "CapabilityDetector" (gorisk.CapabilityDetector)
  • "RiskScorer" (gorisk.RiskScorer)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PluginDir

func PluginDir() string

PluginDir returns the default directory where gorisk looks for plugins. It is $HOME/.gorisk/plugins on Unix and %APPDATA%\gorisk\plugins on Windows.

Types

type CapabilityDetector

type CapabilityDetector interface {
	Language() string
	DetectFile(path string) (map[string]float64, error)
}

CapabilityDetector mirrors gorisk.CapabilityDetector to avoid an import cycle. Plugins are loaded at runtime; we use the same method signatures.

type LoadedPlugin

type LoadedPlugin struct {
	Path     string
	Detector CapabilityDetector // nil if not exported
	Scorer   RiskScorer         // nil if not exported
}

LoadedPlugin holds the symbols resolved from a single .so file.

func Load

func Load(path string) (LoadedPlugin, error)

Load opens a single plugin .so file and resolves known symbols.

func LoadDir

func LoadDir(dir string) ([]LoadedPlugin, []error)

LoadDir loads all .so plugin files from dir. Errors for individual files are collected and returned together; valid plugins are still returned.

type RiskScorer

type RiskScorer interface {
	Name() string
	Score(pkg string, caps []string) float64
}

RiskScorer mirrors gorisk.RiskScorer.

Jump to

Keyboard shortcuts

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