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

revision

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package revision records when a project's API surface last changed.

The date is the whole point, and so is what it is not: it is not a build timestamp. A timestamp moves on every regeneration, so two clients built a month apart against an unchanged API look a month apart when they are identical, and the number is noise within a week. This moves only when the document's hash does — which is to say, only when the surface a client was built against actually changed.

The file is committed. That is what makes `git log` a record of when the API moved, and what makes a clean checkout regenerate the same bytes rather than stamping today over a date somebody chose in March.

Index

Constants

View Source
const Layout = "2006-01-02"

Layout is how a revision is written. A date and nothing finer: the question it answers is "how many releases behind is this client", and an hour has never been the unit of that answer.

View Source
const Name = ".rig/revision.json"

Name is where the record lives, relative to the project root.

It sits beside .rig/manifest.json and is committed where that one is not: the manifest describes this machine's last run, and this describes the project.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	// Revision is the date the surface last changed, as YYYY-MM-DD.
	Revision string `json:"revision"`
	// Hash is the document hash that date belongs to.
	Hash string `json:"hash"`
}

File is the recorded pair.

Both halves are needed. The hash alone cannot say when, and the date alone cannot say whether the surface has moved since.

func Load

func Load(root string) (File, error)

Load reads the record for a project.

A missing file is not an error: a project that has never generated has nothing to remember, and the zero File resolves to today on the next run.

func Resolve

func Resolve(prev File, hash string, today time.Time) (File, bool)

Resolve decides what the revision is now.

Same hash as the recorded one, and a date to go with it, means the surface has not moved: the old date stands, and every generator produces the byte it produced yesterday. Anything else — a different hash, a record that was never written, a date somebody deleted — is today.

It is pure and takes its clock as an argument, so the decision can be tested without waiting a day for the interesting case.

func (File) Save

func (f File) Save(root string) error

Save writes the record.

Jump to

Keyboard shortcuts

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