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

facadegen

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package facadegen writes a facade package: one that re-exports another package's whole exported API under a new import path, so github.com/weftgo/weft (the framework) offers the loop that github.com/weftgo/weft/core (the slim module) implements, under the same names. Types become aliases, constants and variables become re-declarations bound to the originals, and functions become one-line wrappers — a wrapper rather than a func variable so the signature, its generics and its doc comment survive on pkg.go.dev.

The facade is generated from source (go/ast), never hand-written: a release regenerates it (go generate ./...) and TestFacadesAreComplete fails the build when the facade and its source disagree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(opts Options) ([]byte, error)

Generate renders the facade source for opts.

Types

type Decl

type Decl struct {
	Kind string // "type", "func", "const" or "var"
	Name string
}

Decl is one exported top-level declaration.

func Exported

func Exported(dir string) ([]Decl, error)

Exported lists the exported top-level declarations of the package in dir, in source order. Methods belong to their types and are not listed.

type Options

type Options struct {
	// SrcDir is the directory of the package being re-exported.
	SrcDir string
	// SrcImport is its import path; SrcName the local name the facade
	// imports it under (shown on pkg.go.dev as the alias target).
	SrcImport, SrcName string
	// DstPkg is the facade's package name.
	DstPkg string
	// Rewrite maps an import path the source's signatures use to the
	// path the facade should name instead — the layers' facades name
	// github.com/weftgo/weft where the source names its core, so the
	// documented signatures read weft.Model, not core.Model. The local
	// name is the rewritten path's last element.
	Rewrite map[string]string
	// Generate is the go:generate line to record, verbatim, without
	// the "//go:generate " prefix.
	Generate string
}

Options describe one facade.

Jump to

Keyboard shortcuts

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