apifreeze

package
v1.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package apifreeze provides stable public API snapshots for contract tests. It combines exported AST declaration shape with go/types semantics for method sets, constant values, and variable types. Implementation bodies, private struct fields, and private concrete methods stay unfrozen.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(want, got string) string

Diff returns a line-oriented LCS diff suitable for a test failure. The expected snapshot is prefixed with '-' and the observed surface with '+'.

Types

type Declaration

type Declaration struct {
	Kind     string
	Name     string
	Receiver string
	Members  []string
	Text     string
}

Declaration is one exported package declaration. Receiver is populated for methods; Name is the unqualified exported identifier used by vocabulary guards.

type Surface

type Surface struct {
	Declarations []Declaration
}

Surface is the complete application-facing source surface of one package.

func Read

func Read(dir string) (Surface, error)

Read parses the build-selected non-test Go files in dir and returns their exported API. Declarations are sorted by stable semantic keys; field order within a struct remains source order because it affects layout.

func (Surface) String

func (s Surface) String() string

String renders a stable, readable golden snapshot.

Jump to

Keyboard shortcuts

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