Documentation
¶
Overview ¶
Package ormgen writes the row scanners the ORM uses instead of reflection, and registers the models embedding orm.Model: one orm_scanners_gen.go per package that declares a model some orm.For[T]() names or that embeds orm.Model[T], its init calling orm.Register[T]() for the latter. orm generate (and the ormgen command, for go:generate) writes it to disk; the orm command's migration tool overlays it when it isn't there.
Index ¶
Constants ¶
const ( OutName = "orm_scanners_gen.go" OutTestName = "orm_scanners_gen_test.go" OutXTestName = "orm_scanners_x_gen_test.go" // a package_test package )
The files ormgen writes in a model's package: OutTestName for models declared in _test.go files.
Variables ¶
This section is empty.
Functions ¶
func EmbedsModel ¶
EmbedsModel is whether n is a model of its own orm.Model: a struct embedding orm.Model[n], directly or through embedded structs (by pointer or twice too: Register then fails boot saying why). A struct holding another model's orm.Model (one embedding a model to add fields) isn't one.
func Generate ¶
Generate is the scanner files of the models the packages under dir name with orm.For or declare embedding orm.Model, by path.
func Missing ¶
Missing is the files Generate makes under dir that the tree lacks or holds out of date: what a tool overlays onto a build so the models are registered and scanned without the files being written.
func Packages ¶
Packages is the patterns (./dir) of the packages under dir that may declare models with orm.For or orm.Model.
Types ¶
type Config ¶
type Config struct {
Patterns []string
Tests bool
// Skipped hears each model no code is generated for, and why: it is
// read by reflection at run time instead.
Skipped func(model, reason string)
}
Config is what Generate loads: Patterns (default ./...), and Tests to take the models of test files too.