Documentation
¶
Overview ¶
Package sqlc provides the sqlc codegen plugin entry point and configuration parsing for sqlc-gen-template.
Index ¶
Constants ¶
const PluginName = "template"
PluginName is the name under which this plugin is typically registered in sqlc.yaml.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
func Generate(_ context.Context, req *plugin.GenerateRequest) (*plugin.GenerateResponse, error)
Generate is the sqlc codegen entry point. It parses plugin options, walks the configured template directory, renders each template against the raw GenerateRequest, and returns the produced files.
Types ¶
type Options ¶
type Options struct {
// TemplatesDir is the directory to walk for *.tmpl files. Required.
// Relative paths resolve against the sqlc configuration directory.
TemplatesDir string `json:"templates_dir"`
// Extra is a free-form map surfaced to templates as .Options.Extra.
Extra map[string]any `json:"extra,omitempty"`
}
Options holds plugin-specific options decoded from the JSON payload that sqlc sends in GenerateRequest.PluginOptions.
func ParseOptions ¶
ParseOptions decodes the JSON plugin options payload. Unknown fields are rejected to catch typos in sqlc.yaml. An empty payload yields zero-value Options, which then fails Validate().