scaffold

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package scaffold writes the files for a new module, app or service.

Generated code here is a starting point that already does the things people forget: the repository is tenant-scoped, the list endpoint is paginated with an allow-listed sort, the create route carries a guard, the update DTO uses pointers so a PATCH can set a field to false, and the service returns typed errors rather than strings. Deleting a line you do not need is cheaper than remembering a line you did.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(root string, files []File, dryRun bool) ([]string, error)

Write creates the files under root.

It never overwrites. A generator that clobbers an existing file destroys work with no undo, and the one time it happens costs more than every keystroke the generator ever saved.

Types

type Data

type Data struct {
	// GoModule is the importing module path, e.g. "github.com/acme/billing".
	GoModule string
	// AppsDir is where domains live, e.g. "apps".
	AppsDir string
	// App is the domain, e.g. "catalog".
	App string
	// Module is the resource, e.g. "products".
	Module string
	// Package is Module as a Go identifier, e.g. "products".
	Package string
	// Entity is the singular Go type, e.g. "Product".
	Entity string
	// Receiver is a short receiver name, e.g. "s".
	Receiver string
	// Service is the service name for a scaffolded service.
	Service string
	// contains filtered or unexported fields
}

Data drives the templates.

func NewData

func NewData(goModule, appsDir, app, mod string) Data

NewData derives the template data from an app/module pair.

func (Data) AppFile

func (d Data) AppFile() string

AppFile is the domain aggregator file name.

func (Data) ImportBase

func (d Data) ImportBase() string

ImportBase is the import path of the module directory.

func (Data) ModuleFile

func (d Data) ModuleFile() string

ModuleFile is the module declaration file name.

func (Data) WithConfig

func (d Data) WithConfig(c *project.Config) Data

WithConfig applies the repository's conventions from icpt.json.

type File

type File struct {
	Path    string
	Content string
}

File is one generated file.

func AppFile

func AppFile(d Data) (File, error)

AppFile renders the app aggregator.

func Module

func Module(d Data) ([]File, error)

Module renders every file of a new module, honouring the repository's layout from icpt.json.

func Service

func Service(d Data) ([]File, error)

Service renders a new service skeleton.

Jump to

Keyboard shortcuts

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