Help us shape the future of Go! Take the 2026 Go Developer Survey

gen

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package gen defines the Forge generator framework: a pluggable Generator interface, a registry, and a FileSet output collector. Each concrete target (docs, mcp server, Go/TS/Python SDKs, tool-pack manifest) lives in a subpackage that registers itself via init(); the CLI blank-imports those subpackages to populate the registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Names

func Names() []string

Names returns the sorted list of registered target names.

func Register

func Register(g Generator)

Register adds a generator. Intended to be called from a subpackage init().

Types

type FileSet

type FileSet struct {
	Files map[string][]byte
}

FileSet collects generated files keyed by relative path.

func NewFileSet

func NewFileSet() *FileSet

NewFileSet returns an empty FileSet.

func (*FileSet) Add

func (f *FileSet) Add(path string, content []byte)

Add stores raw file content at a relative path.

func (*FileSet) AddString

func (f *FileSet) AddString(path, content string)

AddString stores string content at a relative path.

func (*FileSet) Merge

func (f *FileSet) Merge(prefix string, other *FileSet)

Merge folds another FileSet's files into this one, prefixing their paths.

func (*FileSet) Paths

func (f *FileSet) Paths() []string

Paths returns the sorted relative paths in the set.

func (*FileSet) WriteDir

func (f *FileSet) WriteDir(root string) error

WriteDir writes every file under root, creating parent directories.

type Generator

type Generator interface {
	// Name is the target identifier, e.g. "docs", "go-sdk", "mcp-http".
	Name() string
	// Generate renders the API into a FileSet.
	Generate(api *ir.API, opts Options) (*FileSet, error)
}

Generator produces files from an IR.API.

func Get

func Get(name string) (Generator, bool)

Get returns a generator by name.

type Options

type Options struct {
	Prefix      string // tool / symbol name prefix
	PackageName string // package/namespace name for code targets
	ModulePath  string // module path for the Go SDK (go.mod)
}

Options parameterize a generation run.

Directories

Path Synopsis
Package docs generates Markdown API reference documentation from the IR.
Package docs generates Markdown API reference documentation from the IR.
Package gosdk is a Forge generator that emits a self-contained Go client SDK for an API described by the IR.
Package gosdk is a Forge generator that emits a self-contained Go client SDK for an API described by the IR.
Package javasdk is a Forge generator that emits a Java client SDK for an API described by the IR.
Package javasdk is a Forge generator that emits a Java client SDK for an API described by the IR.
Package mcpserver generates a standalone Go MCP server for an API.
Package mcpserver generates a standalone Go MCP server for an API.
Package pysdk is a Forge generator that emits a Python client SDK (client.py + pyproject.toml + README.md) for an API described by the IR.
Package pysdk is a Forge generator that emits a Python client SDK (client.py + pyproject.toml + README.md) for an API described by the IR.
Package tssdk is a Forge generator that emits a TypeScript client SDK (client.ts + package.json + README.md) for an API described by the IR.
Package tssdk is a Forge generator that emits a TypeScript client SDK (client.ts + package.json + README.md) for an API described by the IR.

Jump to

Keyboard shortcuts

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