decorgen

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package decorgen generates decorators: for each named interface, a Decorated<Name> type whose every operation — a method taking a context.Context first and returning an error last — runs through a decorate.Subject (the Exec every tier's Base embeds), named by the method, and whose other methods pass straight through. It is the Go counterpart of Python's runtime decorate(client, base): a component's custom operations get its tier's layers without a hand-written wrapper per method. The cmd/decorgen binary runs it from a go:generate directive.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(cfg Config) ([]byte, error)

Generate returns the gofmt'd source declaring a Decorated<Name> for each interface in cfg. An unknown, generic or non-interface name is CodeInvalidInput; a package that fails to load is CodeInternal.

Types

type Config

type Config struct {
	// Source is the package pattern holding the interfaces ("." or an import path),
	// resolved from Dir.
	Source string

	// Dir is the directory patterns resolve from; empty is the working directory.
	Dir string

	// Package is the generated file's package name.
	Package string

	// PackagePath is the generated file's import path, so the types it declares are
	// written unqualified; empty qualifies every named type.
	PackagePath string

	// Interfaces names the interfaces to decorate, in output order.
	Interfaces []string
}

Config selects the interfaces to decorate and where the generated code lives.

Directories

Path Synopsis
cmd
decorgen command
Command decorgen writes the decorators decorgen.Generate builds, for a go:generate directive:
Command decorgen writes the decorators decorgen.Generate builds, for a go:generate directive:

Jump to

Keyboard shortcuts

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