Documentation
¶
Overview ¶
pkg/plugin/plugin.go Plugin system for loading native Go plugins at runtime.
Plugins are Go shared libraries (.so on Linux/macOS) that implement the Plugin interface. They can export functions, variables, and other values to xxlang code.
Usage from xxlang:
import "plugin/myplugin" myplugin.hello()
Building a plugin:
go build -buildmode=plugin -o myplugin.so myplugin.go
pkg/plugin/plugin_native.go Native plugin loading for supported platforms (Linux, macOS, FreeBSD).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Registry = struct { sync.RWMutex plugins map[string]Plugin }{ // contains filtered or unexported fields }
Registry tracks loaded plugins. It is safe for concurrent use.
Functions ¶
Types ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles loading .so plugin files.
func NewLoader ¶
func NewLoader() *Loader
NewLoader creates a new plugin loader with default search paths.
type Plugin ¶
type Plugin interface {
// Name returns the plugin name (used as plugin/name in imports).
// This should match the filename (without .so extension).
Name() string
// Exports returns the module's exported symbols.
// The map keys are the names accessible from xxlang code.
Exports() map[string]objects.Object
}
Plugin is the interface that native plugins must implement. Plugins are loaded from .so files and register their exports through this interface.