Go Plugin
A structured plugin registry for Go with deterministic lifecycle management and lightweight discovery helpers.
Features
- Deterministic Registry: Preserve insertion order for predictable startup and shutdown.
- Factory Support: Register deferred constructors for dynamic plugin creation.
- Reflection Discovery: Discover plugin implementations from runtime values.
- Optional Router Integration: Bridge route-providing plugins into
go-module-router.
Installation
go get github.com/mirkobrombin/go-plugin
Quick Start
package main
import "github.com/mirkobrombin/go-plugin/pkg/plugin"
type samplePlugin struct{}
func (samplePlugin) Name() string { return "sample" }
func (samplePlugin) Start() error { return nil }
func (samplePlugin) Stop() error { return nil }
func main() {
registry := plugin.NewRegistry()
if err := registry.Register(samplePlugin{}); err != nil {
panic(err)
}
_ = registry.StartAll()
_ = registry.StopAll()
}
Documentation
License
This project is licensed under the MIT License. See the LICENSE file for details.