gofasta generate
gofasta generate (shorthand g) writes new layers into an existing project and patches the files that have to know about them — the DI container, the route index, the GraphQL schema. Generated output is ordinary Go: no reflection-driven runtime, nothing that stops compiling if you edit it by hand.
gofasta generate <subcommand> [args...]
gofasta g <subcommand> [args...] # same thingEvery subcommand honors --dry-run (print the create/patch plan without writing) and the global --json flag.
Full-stack scaffold
g scaffold— A complete CRUD resource across every layer: model, repository, service, controller, routes, DTOs, migration, and DI provider.
Per-layer generators
Each of these generates its own layer plus the prerequisite layers below it, so you can stop at the depth you actually need.
g model— A GORM model with typed fields plus its migration pair.g repository— Model, migration, repository interface, and implementation. Data access without an HTTP surface.g service— A service interface and implementation with its prerequisite layers. Stops short of controller and routes.g controller— A REST controller with CRUD handlers and every layer beneath it.g dto— Request and response DTOs for a resource.g migration— An.up.sql/.down.sqlpair in the SQL flavor of the driver inconfig.yaml, for schema changes with no Go model.g route— A per-resource chi routes file, withindex.routes.gopatched to mount it.g resolver— Patches the GraphQL resolver root with a service dependency and re-runs gqlgen.g provider— The Wire provider set that ties service, repository, and controller together.
Adding to what already exists
These patch existing files through the AST — idempotent, and they preserve comments and blank lines.
g method— Add a method to an existing service interface and implementation.g repo-method— The repository-layer twin ofg method.g field— Add a column: patches the model and the Create/Update/Response DTOs, and writes the paired migration.g endpoint— Add one REST endpoint to an existing resource — controller stub, chi registration, and optionally the service interface.g middleware— Wrap an existing route’s handler with a middleware.g relation— Add a GORM association (belongs_to,has_many,has_one), including the FK migration where one is needed.g rename— Cross-file rename of a field across model, DTOs, service, tests, and repository, plus a rename migration. Preview by default.
Asynchronous work
g job— A scheduled background job implementing thescheduler.Jobinterface.g task— An asynq-backed async task: constant, payload struct, handler, and enqueue helper, wired into the queue worker.g email-template— An HTML email template with its Go template file and registration entry for the mailer renderer.
Testing
g mock— A testify mock satisfying a Go interface, with a compile-time conformance check.--allrefreshes every mock;--checkdetects drift in CI.
Last updated on