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

source

package
v1.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package source verifies and persists bounded edits to captured Go properties. It is development tooling: producers are trusted programs, not sandboxed input.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	// contains filtered or unexported fields
}

Change retains the verified candidate and its input revisions privately.

func Prepare

func Prepare(ctx context.Context, producer GoProducer, target Target, proposal export.PropsProposal) (*Change, error)

Prepare runs the actual producer, its existing proposal operation and a fresh build with the candidate Go overlay. All three must agree on the full export. Only existing keyed string literals can change; no source files are written. Temporary overlays and module copies are removed before returning.

func (*Change) Apply

func (c *Change) Apply(ctx context.Context) error

Apply rechecks the producer's build inputs and replaces exactly one source file using a same-directory atomic rename. Unix advisory locking serializes cooperating writers; other platforms refuse. An unrelated editor can still race the last check and rename, so this is not filesystem compare-and-swap. File mode is preserved; ownership, ACLs and extended attributes are not copied.

func (*Change) Review

func (c *Change) Review() Review

Review returns the complete candidate file and source/export revisions.

type GoProducer

type GoProducer struct {
	Dir, Package string
	Args         []string
}

GoProducer selects a caller-owned main package in Dir, its module root. Package is . or a relative ./path. Args select the full source composition. The producer must emit one DesignExport JSON object, and accept the same Args followed by --proposal with PropsProposal JSON on stdin. Builds disable cgo, workspaces and GOFLAGS; custom build configurations are not supported yet. Constructors must be deterministic and free of external side effects.

type Review

type Review struct {
	File         string `json:"file"`
	BeforeSHA256 string `json:"beforeSHA256"`
	AfterSHA256  string `json:"afterSHA256"`
	BaseSHA256   string `json:"baseSHA256"`
	ResultSHA256 string `json:"resultSHA256"`
	Source       string `json:"source"`
}

Review is detached evidence, not authority to apply arbitrary source bytes.

type Target

type Target struct {
	File         string
	Line, Column int
	SHA256       string
}

Target locates the start of an existing capture call in an owning module. Column zero admits a unique call on Line. SHA256 addresses the entire file, independently of the proposal's semantic export hash.

Jump to

Keyboard shortcuts

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