apicompat

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// ConfigSchemaVersion is the supported compatibility configuration schema.
	ConfigSchemaVersion = 1
)

Variables

This section is empty.

Functions

func BasePath

func BasePath(configPath string, variant Variant) string

BasePath returns a delta variant's full baseline path.

func BaselinePath

func BaselinePath(configPath string, variant Variant) string

BaselinePath returns a variant baseline relative to the configuration file.

func Compare

func Compare(baseline, current Manifest) error

Compare returns nil only when the checked-in and current APIs are identical. Exact comparison makes additive changes intentional baseline reviews too.

Types

type Config

type Config struct {
	Schema                  int       `json:"schema"`
	Module                  string    `json:"module"`
	ExcludedPackagePrefixes []string  `json:"excludedPackagePrefixes"`
	Variants                []Variant `json:"variants"`
}

Config defines the module, exclusions, and build variants whose public APIs are frozen.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig reads and validates a compatibility configuration.

func (Config) BaselineOwner

func (cfg Config) BaselineOwner(variant Variant) Variant

BaselineOwner returns the first configured variant for a shared baseline. Only that owner may update the baseline without also checking every selected alias variant.

func (Config) SelectVariants

func (cfg Config) SelectVariants(names []string) ([]Variant, error)

SelectVariants resolves requested variant names in configuration order.

func (Config) Validate

func (cfg Config) Validate() error

Validate rejects ambiguous or unsafe compatibility configuration.

type Delta

type Delta struct {
	Base    string
	Removed []string
	Added   []string
}

Delta describes the exact removals and additions relative to a full baseline.

func ManifestDelta

func ManifestDelta(base, current Manifest, baseName string) (Delta, error)

ManifestDelta computes a deterministic overlay from base to current.

func ParseDelta

func ParseDelta(body string) (Delta, error)

ParseDelta validates and parses a checked-in baseline overlay.

func (Delta) Render

func (delta Delta) Render() string

Render returns the deterministic, human-reviewable delta representation.

type Manifest

type Manifest struct {
	Packages []PackageAPI
}

Manifest is the canonical public API for all discovered library packages.

func ApplyDelta

func ApplyDelta(base Manifest, delta Delta) (Manifest, error)

ApplyDelta reconstructs a variant manifest and rejects stale overlays.

func ParseManifest

func ParseManifest(body string) (Manifest, error)

ParseManifest validates and parses a checked-in baseline.

func Snapshot

func Snapshot(
	ctx context.Context,
	root string,
	cfg Config,
	variant Variant,
) (Manifest, error)

Snapshot loads and renders the public library API for one build variant.

func (Manifest) Render

func (manifest Manifest) Render() string

Render returns the deterministic, human-reviewable baseline representation.

type PackageAPI

type PackageAPI struct {
	Path         string
	Name         string
	Declarations []string
}

PackageAPI is the canonical exported API for one import path.

type Variant

type Variant struct {
	Name        string   `json:"name"`
	GOOS        string   `json:"goos"`
	GOARCH      string   `json:"goarch"`
	CGOEnabled  bool     `json:"cgoEnabled"`
	Tags        []string `json:"tags,omitempty"`
	Baseline    string   `json:"baseline"`
	Base        string   `json:"base,omitempty"`
	Description string   `json:"description"`
}

Variant defines one build context and the baseline it must match.

Jump to

Keyboard shortcuts

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