generator

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGoVersion = "1.23.0"

Variables

View Source
var StandardManifest = []FileSpec{
	{Source: "cmd/api/main.go.tmpl", Destination: "cmd/api/main.go", Mode: 0o644, IsTemplate: true},
	{Source: "configs/config.yaml.tmpl", Destination: "configs/config.yaml", Mode: 0o644, IsTemplate: true},
	{Source: "internal/app/app.go.tmpl", Destination: "internal/app/app.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/config/config.go.tmpl", Destination: "internal/config/config.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/config/config_test.go.tmpl", Destination: "internal/config/config_test.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/server/router.go.tmpl", Destination: "internal/server/router.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/server/server.go.tmpl", Destination: "internal/server/server.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/middleware/error_handler.go.tmpl", Destination: "internal/middleware/error_handler.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/middleware/logger.go.tmpl", Destination: "internal/middleware/logger.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/middleware/recovery.go.tmpl", Destination: "internal/middleware/recovery.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/middleware/request_id.go.tmpl", Destination: "internal/middleware/request_id.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/modules/health/handler.go.tmpl", Destination: "internal/modules/health/handler.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/modules/health/routes.go.tmpl", Destination: "internal/modules/health/routes.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/modules/user/dto.go.tmpl", Destination: "internal/modules/user/dto.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/modules/user/model.go.tmpl", Destination: "internal/modules/user/model.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/modules/user/repository.go.tmpl", Destination: "internal/modules/user/repository.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/modules/user/memory_repository.go.tmpl", Destination: "internal/modules/user/memory_repository.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/modules/user/service.go.tmpl", Destination: "internal/modules/user/service.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/modules/user/handler.go.tmpl", Destination: "internal/modules/user/handler.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/modules/user/routes.go.tmpl", Destination: "internal/modules/user/routes.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/shared/apperror/error.go.tmpl", Destination: "internal/shared/apperror/error.go", Mode: 0o644, IsTemplate: true},
	{Source: "internal/shared/response/response.go.tmpl", Destination: "internal/shared/response/response.go", Mode: 0o644, IsTemplate: true},
	{Source: "tests/integration/api_test.go.tmpl", Destination: "tests/integration/api_test.go", Mode: 0o644, IsTemplate: true},
	{Source: "dot.env.example.tmpl", Destination: ".env.example", Mode: 0o644, IsTemplate: true},
	{Source: "dot.gitignore.tmpl", Destination: ".gitignore", Mode: 0o644, IsTemplate: true},
	{Source: "Dockerfile.tmpl", Destination: "Dockerfile", Mode: 0o644, IsTemplate: true},
	{Source: "go.mod.tmpl", Destination: "go.mod", Mode: 0o644, IsTemplate: true},
	{Source: "go.sum.tmpl", Destination: "go.sum", Mode: 0o644, IsTemplate: false},
	{Source: "README.md.tmpl", Destination: "README.md", Mode: 0o644, IsTemplate: true},
}

StandardManifest is intentionally explicit so additions and file permissions are reviewable and deterministic.

Functions

func ValidateModulePath

func ValidateModulePath(modulePath string) error

ValidateModulePath applies the same module path rules as the Go toolchain.

func ValidateProjectName

func ValidateProjectName(name string) error

ValidateProjectName rejects ambiguous names and all path-like inputs.

Types

type FileSpec

type FileSpec struct {
	Source      string
	Destination string
	Mode        fs.FileMode
	IsTemplate  bool
}

FileSpec maps one embedded source file to a generated project file.

type Generator

type Generator struct {
	Templates fs.FS
	Root      string
	Specs     []FileSpec
}

Generator renders a manifest from an fs.FS.

func New

func New(templateFS fs.FS, root string) *Generator

func (*Generator) Generate

func (g *Generator) Generate(options Options) (result Result, returnErr error)

type Options

type Options struct {
	Name       string
	ModulePath string
	OutputDir  string
	DryRun     bool
	GoVersion  string
	CLIVersion string
}

Options controls one project generation operation.

type Result

type Result struct {
	TargetDir string
	Files     []string
	DryRun    bool
}

Result describes the target and deterministic list of generated files.

type TemplateData

type TemplateData struct {
	ProjectName string
	ModulePath  string
	GoVersion   string
	CLIVersion  string
}

TemplateData is available to every project template.

Jump to

Keyboard shortcuts

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