generator

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package generator provides migration and seeder file generation using Go text/template and embedded template files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseModulePath

func ParseModulePath(goModPath string) (string, error)

ParseModulePath reads a go.mod file and extracts the module path from the module directive. It returns an error if the file cannot be read or the module directive is missing or malformed.

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator generates migration and seeder files from templates.

func NewGenerator

func NewGenerator(outputDir string) *Generator

NewGenerator creates a new Generator that writes files to outputDir.

func (*Generator) Factory

func (g *Generator) Factory(description string) (string, error)

Factory generates a factory file and returns the full filepath. The filename follows the pattern description_factory.go.

func (*Generator) Migration

func (g *Generator) Migration(description string, opts MigrationOptions) (string, error)

Migration generates a migration file and returns the full filepath. The filename follows the pattern YYYY_MM_DD_HHMMSS_RRRR_description.go. The opts parameter controls whether the template includes pre-populated Schema_Builder calls for --create or --table flags.

func (*Generator) Seeder

func (g *Generator) Seeder(description string) (string, error)

Seeder generates a seeder file and returns the full filepath. The filename follows the pattern description_seeder.go.

type InitResult

type InitResult struct {
	DirsCreated  []string
	FilesCreated []string
	FilesSkipped []string
}

InitResult summarizes what the scaffolder created or skipped.

type InitScaffolder

type InitScaffolder struct {
	// contains filtered or unexported fields
}

InitScaffolder handles all file system operations for the init command.

func NewInitScaffolder

func NewInitScaffolder(baseDir, modulePath string, force bool, stdout, stderr io.Writer) *InitScaffolder

NewInitScaffolder creates a new InitScaffolder with the given configuration.

func (*InitScaffolder) Scaffold

func (s *InitScaffolder) Scaffold() (*InitResult, error)

Scaffold creates the project directory structure and generated files. It returns an InitResult summarizing what was created or skipped.

type MigrationOptions

type MigrationOptions struct {
	// CreateTable pre-populates Up() with a Schema_Builder Create call.
	CreateTable string
	// AlterTable pre-populates Up() with a Schema_Builder Alter call.
	AlterTable string
}

MigrationOptions configures optional flags for migration generation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL