Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run processes SQLC-generated query files and qualifies bare model type references by prefixing them with a package alias and injecting the corresponding import. If SQLC v2+ native model qualification is detected via isSQLCModern(), it logs a message and exits without modifying any files.
Workflow:
- Check for native SQLC qualification support; if present, skip processing.
- Parse the models file at modelPath and collect all struct type names.
- Derive the package alias from modelImport (last path element).
- Glob for all query files matching queryGlob.
- For each file: a) Parse its AST and traverse all identifiers. b) When an identifier matches a model name and is not already part of a selector, replace it with `alias.Identifier`. c) Ensure the import for modelImport is present. d) Rewrite the file in place with `go/format`.
Parameters:
- modelPath: Path to the Go source file defining your models.
- queryGlob: Glob pattern to match SQLC‑generated `.sql.go` files.
- modelImport: Import path for your external models package.
Returns:
- error: Any error encountered while parsing, globbing, or writing files. Returns nil if native SQLC qualification is enabled or if all files are successfully processed.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.