stubs

package
v3.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileName

func FileName(method, path string) string

FileName returns the canonical .linespec stub file name for a route. Example: POST /api/v1/users → "post_api_v1_users.linespec"

func FormatJSON

func FormatJSON(results []Result) ([]byte, error)

FormatJSON formats stub results as a JSON array for --dry-run --format json output.

func FormatTable

func FormatTable(results []Result) string

FormatTable formats stub results as a human-readable table for --dry-run output. Each row shows the action (write/skip), the output file path, and the source route.

func Generate

func Generate(in Input) string

Generate produces the content of a .linespec stub for the given input. The output is syntactically valid DSL with # TODO comments guiding what to fill in.

Types

type BoundaryHit

type BoundaryHit struct {
	Protocol  string // postgresql, mysql, redis, http, kafka, rabbitmq
	Direction string // read, write, both
	Target    string // table name, URL base, topic, or "" when unresolved
	Dynamic   bool   // true when the call site could not be statically resolved
}

BoundaryHit is a protocol boundary hit detected in a handler's call chain. Produced by pkg/discover/boundaries (Phase 2); consumed here for stub generation.

type Input

type Input struct {
	Route      routes.Route
	Boundaries []BoundaryHit
}

Input is the combined route and boundary data for generating one stub file.

type Result

type Result struct {
	FilePath string
	Method   string // HTTP method of the route (uppercased)
	Path     string // URL path of the route
	Content  string
	Skipped  bool
}

Result is the outcome of generating a single stub. Content is always populated; Skipped is true when the file already existed.

func Plan

func Plan(dir string, inputs []Input) []Result

Plan computes what Write would produce without touching the filesystem. Results show which files would be created (Skipped=false) vs skipped (Skipped=true) based on whether each file already exists in dir.

func Write

func Write(dir string, inputs []Input) ([]Result, error)

Write generates and writes stub files to dir. Files are named by FileName. Existing files are skipped and reported with Skipped=true. The output directory is created if it does not exist.

Jump to

Keyboard shortcuts

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