scaffold

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scaffold generates Ohm application, handler, migration, resource, and replay-test files.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedDatabase = errors.New("unsupported database")

ErrUnsupportedDatabase reports an unknown generated database target.

Functions

func GenerateApp

func GenerateApp(cfg App) error

GenerateApp writes a new Ohm application skeleton to cfg.Destination.

func GenerateMigration

func GenerateMigration(cfg Migration) (string, error)

GenerateMigration writes a timestamped goose migration file and returns its path.

Types

type App

type App struct {
	Name        string
	Module      string
	Destination string
	Database    Database
	OhmVersion  string
}

App describes a generated Ohm application.

type Database

type Database string

Database identifies the generated application's database default.

const (
	// DatabasePostgres generates a Postgres application using pgx.
	DatabasePostgres Database = "postgres"
	// DatabaseSQLite generates a SQLite application using modernc.org/sqlite.
	DatabaseSQLite Database = "sqlite"
)

type Handler

type Handler struct {
	Name string
	Dir  string
}

Handler describes generated handler files.

type HandlerResult

type HandlerResult struct {
	CreatedFiles    []string
	RegisterFile    string
	RegisterUpdated bool
	RoutePath       string
}

HandlerResult describes the files changed by GenerateHandler.

func GenerateHandler

func GenerateHandler(cfg Handler) (HandlerResult, error)

GenerateHandler writes a handler and wires its route into handlers.Register.

type Migration

type Migration struct {
	Name string
	Dir  string
	Now  func() time.Time
}

Migration describes a generated goose migration file.

type ReplayTest

type ReplayTest struct {
	SnapshotPath string
	Dir          string
}

ReplayTest describes a generated replay regression test.

type ReplayTestResult

type ReplayTestResult struct {
	CreatedFile string
}

ReplayTestResult describes the file created by GenerateReplayTest.

func GenerateReplayTest

func GenerateReplayTest(cfg ReplayTest) (ReplayTestResult, error)

GenerateReplayTest writes a Go test that replays a snapshot through the app.

type Resource

type Resource struct {
	Name   string
	Fields []ResourceField
	Dir    string
	Now    func() time.Time
}

Resource describes generated files for an application resource.

type ResourceField

type ResourceField struct {
	Name string
	Type string
}

ResourceField describes a generated resource database field.

type ResourceResult

type ResourceResult struct {
	CreatedFiles    []string
	RegisterFile    string
	RegisterUpdated bool
	RoutePath       string
}

ResourceResult describes the files changed by GenerateResource.

func GenerateResource

func GenerateResource(cfg Resource) (ResourceResult, error)

GenerateResource writes a routed handler skeleton plus database migration and sqlc query files.

Jump to

Keyboard shortcuts

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