moduleindex

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 14 Imported by: ? 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

Overview

Package moduleindex builds the module index of a release from the previous index, the release's packages, its tag and its withdrawals, refusing by the rules module-index.*; reads an index of any version of the format by the places every version keeps; and picks the version of a module for a new attempt: the newest by semver that is not withdrawn and lies in the format's window (format/README.md, sections 2 and 26; R63 spec; R16). The CLI's index and open call it, and api.

Build takes a Release — the previous index as its file, or First, the packages that package modulepackage built or read, the tag and the withdrawals — and gives module-index.json, the canonical text of the index from internal/canonical, or a *Refusal that names every breach of the rules of the index. Read reads an index by its members at their places alone, gives every entry of whatever format version, and takes a version as withdrawn whatever its reason. Newest picks the version of a new attempt, skipping an entry whose format version module-kit does not read. WithLatest marks in the index of a release the withdrawals that the index of the newest release knows, for the CLI's open (R15; R43). Versions are ordered by internal/semver. It checks no signature: spec's release-verify does, where a file enters NovaTrail (R77 spec; R35).

Index

Constants

View Source
const (
	RuleEntriesKept      = "module-index.entries-kept"
	RuleOnePackage       = "module-index.one-package"
	RuleKnownWithdrawals = "module-index.known-withdrawals"
	RuleVersionAbove     = "module-index.version-above"
)

The rules of the module index, which refuse to build an index rather than a module (format/README.md, sections 7 and 26).

View Source
const File = "module-index.json"

File is the name of the module index among the files of a release of modules (format/README.md, section 26).

Variables

View Source
var (
	// ErrPrevious is a previous index that cannot be read: one built by a later format version than
	// module-kit reads, or one that is not what a build writes — the canonical text of a value valid
	// against the schema of the module index of the version module-kit reads, with teaches in order
	// —, or none where the release is not the first, or one where it is. Such a release fails: it does
	// not start a new index (format/README.md, section 26).
	ErrPrevious = errors.New("the previous index cannot be read")
	// ErrRelease is a release of which no index can be built: a tag that is not one of a release of
	// modules, withdrawals not in the form of $defs/withdrawals, a package that package
	// modulepackage did not build or read, or no version at all to name.
	ErrRelease = errors.New("not a release whose index can be built")
)

The reasons Build builds no index other than the rules of the index, which its error wraps.

View Source
var ErrLatest = errors.New("not an index of a release at or after the release's")

ErrLatest is an index given as the newest that is not an index of a release at or after the one it is given with: it lacks an entry of that release's index, holds one otherwise than it was, or does not keep its withdrawal.

View Source
var ErrNotIndex = errors.New("no module index by the places every version of the format keeps")

ErrNotIndex is a text that Read does not read as a module index: no JSON object, or one whose members at the places every version of the format keeps are not in their forms.

Rules lists the rules of the module index, in the order of the table of section 26 of format/README.md.

Functions

func Build

func Build(r Release) ([]byte, error)

Build builds the module index of a release by the format version module-kit reads, FormatVersion of package module, and gives its file, module-index.json: the canonical text of the index (format/README.md, sections 25 and 26; R63 spec). Every entry of the previous index stands in the new one as it was; a package of a version that the previous index names keeps that entry, its release among it; every other package gets a new entry, which names the release's tag; and last, the release's withdrawals are marked.

A release that breaks a rule of the index gives a *Refusal, with every breach in the order of the module, the version and the rule; the build is refused, rather than an index built without what breaks the rule. Any other error wraps ErrPrevious or ErrRelease, and comes before a refusal: the rules are read only on a release whose previous index, tag, withdrawals and packages are in their forms.

func Newest

func Newest(index formatv0.ModuleIndex, id formatv0.ModuleID) (version formatv0.ModuleVersion, ok bool)

Newest gives the version of the module id that a new attempt takes: the newest by Semantic Versioning of the versions that the index names, of those not withdrawn, whatever the reason, and whose format version module-kit reads, ReadsFormat of package module (format/README.md, section 26; R63 spec; R16). ok is false when the index names no such version. The same version is the one by which a module counts as teaching the anchor skills of its entry (concepts 4 spec). A version not in the form X.Y.Z, which no index that Read or Build gives names, is skipped too.

func Read

func Read(data []byte) (formatv0.ModuleIndex, error)

Read reads a module index of any version of the format by the places that every version keeps, and not by the schema of its own version, which refuses what a later version adds (format/README.md, sections 2 and 26): module_format_version and modules at its root, and module_format_version, package_digest, release, teaches and withdrawn in an entry. A member at another place, which a later version may add, is not read. Those members keep their forms in every version too, so one that is not in its form is no index of any version, and Read gives ErrNotIndex. A version is withdrawn whatever its reason: Withdrawn holds the reason as the index writes it, one that a later version adds among them.

Read gives every entry, of whatever format version, so that the comparison of versions sees every published version of a module (format/README.md, section 27). A pick of a version, Newest, skips an entry whose format version module-kit does not read, rather than refuse the index. Read checks no signature: the index was checked where it entered NovaTrail (R77 spec). Nor does it hold the text to the canonical text, which a later version may change; a name that stands twice in one object, which no build writes, counts by its last member.

func WithLatest added in v0.2.1

func WithLatest(release, latest formatv0.ModuleIndex) (formatv0.ModuleIndex, error)

WithLatest gives the index of a release with the withdrawals that the index of the newest release marks: each entry of release as it is, but withdrawn whenever latest withdraws it, by latest's reason. Only the newest index knows of every withdrawal so far, and a version that it withdraws is no version to show, whatever the release that published it says (format/README.md, section 26; R25 spec, R63 spec). Newest of the index it gives is then the version that the page of samples of canvas takes of a module, as the CLI's open does (R15).

Every later index keeps every entry as it was, and a withdrawal with its reason (module-index.entries-kept, module-index.known-withdrawals). So an entry of release that latest lacks, holds otherwise or does not keep withdrawn gives ErrLatest, and so latest from a release before release's does too; an entry of latest that release lacks, of a later release, is left out. latest may be release itself. Neither index is changed.

Types

type Breach

type Breach struct {
	Rule    string
	Module  formatv0.ModuleID
	Version formatv0.ModuleVersion
	Message string
}

A Breach is a rule of the module index that the build of a release breaks, at the version of a module that breaks it, with what is wrong.

func (Breach) String

func (b Breach) String() string

type Refusal

type Refusal struct {
	Breaches []Breach
}

A Refusal is why Build builds no index: the release breaks rules of the module index, and it names every breach (format/README.md, section 7).

func (*Refusal) Error

func (r *Refusal) Error() string

type Release

type Release struct {
	// Previous is the index of the release before, module-index.json as that release holds it,
	// byte for byte. The first release of modules has none, and says so by First: an empty
	// Previous is no index, so a file that could not be read does not start a new one.
	Previous []byte
	First    bool
	// Tag is the tag of the release, vX.Y.Z, which each new entry names.
	Tag formatv0.Release
	// Packages are the packages of the release, as package modulepackage built or read them. A
	// release may build every module or only those that changed: a package of a version that the
	// previous index names keeps its entry.
	Packages []*modulepackage.Package
	// Withdrawals are the versions that the release withdraws from publication, by module ID and
	// version, each with its reason, as $defs/withdrawals of module-index.schema.json gives them.
	// A release that withdraws none has nil.
	Withdrawals formatv0.Withdrawals
}

A Release is what a release of modules gives the build of its index (format/README.md, section 26): the index of the release before it, its own packages, its tag and its withdrawals.

Jump to

Keyboard shortcuts

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