Plugins¶
goboot is extended at compile time — a plugin is a Go module linked into the
CLI (there is no dynamic .so loading). A plugin contributes any combination of:
annotation schemas, extra analysis, generated files, and SQL dialects.
Using plugins¶
List them in goboot.yaml:
plugins:
- github.com/zombocoder/goboot/plugins/openapi@v0.1.0 # shorthand
- module: github.com/acme/goboot-redis # explicit form
version: v1.3.1
import: github.com/acme/goboot-redis/gobootx # default = module
new: New # default = New
Then run generation as usual:
The stock goboot binary detects the plugins: block and self-bootstraps: it
builds a plugin-aware CLI from the list (cached under .goboot/, keyed by the
plugin set + toolchain), re-execs it, and your plugins are active. A changed
plugin set transparently rebuilds.
GOBOOT_BOOTSTRAP=off goboot generate …runs the plugin-free binary.- For reproducible / offline CI,
goboot plugins syncpins the modules and writes a committedtools/goboot/main.go; drive generation withgo run ./tools/goboot generate ./.... goboot pluginslists configured vs. linked plugins.
Official plugins¶
| Plugin | Capability |
|---|---|
plugins/openapi |
Generator — emits an OpenAPI 3 spec from your routes |
plugins/oracle |
DialectProvider — Oracle SQL dialect (:1, :2) |
plugins/lint |
Analyzer — REST convention warnings |
Writing a plugin¶
A plugin is a module depending on github.com/zombocoder/goboot that exports a
constructor (by convention New) returning a value implementing plugin.Plugin
plus any capability interfaces:
package oracle
func New() *Plugin { return &Plugin{} }
type Plugin struct{}
func (*Plugin) Name() string { return "oracle" }
func (*Plugin) Version() string { return "0.1.0" }
// DialectProvider capability.
func (*Plugin) Dialects() map[string]sqlgen.Dialect {
return map[string]sqlgen.Dialect{"oracle": Dialect{}}
}
Capabilities (implement any subset):
AnnotationProvider— register annotation schemas the compiler recognizes.Analyzer— contribute diagnostics over the analyzed model.Generator— emit additional files alongside the wiring.DialectProvider— register SQL dialects / database drivers.
Analyzer/Generator receive *model.Application, which surfaces
app.Declarations — every annotated declaration with its raw annotations,
including the plugin's own. Filter with app.DeclarationsWith("MyAnnotation")
to drive behavior from an annotation you registered.
Contract
Plugins return diagnostics rather than panic and produce deterministic
output. plugin.APIVersion is the contract version; an incompatible major
fails to compile (compile-time safety).