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

plugin

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package plugin is the local plugin store: verified plugin binaries and manifests under <Dir>/plugins/<qualified name>/<version>/ (0500), and <Dir>/plugins.lock recording what was verified at install time. Every Open re-hashes the binary and the manifest against the lock.

Index

Constants

View Source
const OfficialMarketplace = "official"

OfficialMarketplace is the marketplace name whose plugins have bare names.

Variables

View Source
var (
	ErrTampered     = errors.New("plugin_tampered")
	ErrNotInstalled = errors.New("plugin_not_installed")
)

Functions

func Qualify

func Qualify(marketplace, name string, official bool) string

Qualify returns the store name of a plugin from a marketplace.

Types

type Installed

type Installed struct {
	LockEntry
	Manifest pluginspec.Manifest
	Binary   string
	Tampered bool
}

Installed is a lock entry with its manifest as read from disk. Tampered is set, and Manifest left empty, when the manifest on disk no longer matches the lock.

type LockEntry

type LockEntry struct {
	Name           string `toml:"name"`
	Version        string `toml:"version"`
	Marketplace    string `toml:"marketplace"`
	BinarySHA256   string `toml:"binary_sha256"`
	ManifestSHA256 string `toml:"manifest_sha256"`
	Official       bool   `toml:"official"`
}

LockEntry is one installed plugin in plugins.lock. Name is qualified: bare for the official marketplace, "<marketplace>/<name>" otherwise.

type Store

type Store struct{ Dir string }

func (Store) Install

func (s Store) Install(e LockEntry, binary, manifest []byte) error

Install stores a plugin whose binary and manifest have already been verified against the marketplace, after checking them against e. A previously installed version of the same plugin is replaced.

func (Store) Installed

func (s Store) Installed() ([]Installed, error)

Installed lists the lock with each manifest read and checked.

func (Store) Open

func (s Store) Open(name string) (*os.File, Installed, error)

Open opens an installed plugin's binary and checks, from the opened file itself, that it still hashes to the lock entry; the returned file is positioned at its start and is the one to execute.

func (Store) Remove

func (s Store) Remove(name string) error

Remove uninstalls a plugin by its qualified name.

Jump to

Keyboard shortcuts

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