pluginbuild

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 5 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

Overview

Package pluginbuild derives a best-effort `go build` configuration for a Go plugin that a given binary should be able to load, and explains differences between two binaries' build information.

plugin.Open refuses a plugin when any package linked into both the plugin and the host was compiled differently: "plugin was built with a different version of package ...". Many inputs change that: the toolchain, -trimpath, -race, GOEXPERIMENT, the architecture level, compiler flags, cgo flags and headers, and the source of every shared dependency. A binary's build information (`go version -m`) records only some of them, and some only partly (only the last of several -gcflags, no cgo flags under -trimpath, no content identity for vendored or replaced modules). So a Config makes a loadable build likely, never certain: whether the host accepts a plugin is decided only by the host's loader (`nornicdb stemmer check`).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Differences

func Differences(target, plugin *debug.BuildInfo) []string

Differences lists the recorded differences between a target binary's and a plugin's build information that can make the target refuse the plugin: the toolchain, build settings, and modules both link with a different version, checksum or replacement. It explains a refusal; it never decides one, since build information does not record everything that matters.

Types

type Config

type Config struct {
	// GoVersion is the release of the toolchain that built the binary, e.g.
	// "go1.26.9", without the experiment suffix. The plugin must be built by
	// the same release.
	GoVersion string
	// Flags are `go build` flags, e.g. -trimpath, -race, -tags.
	Flags []string
	// Env are KEY=VALUE settings for the `go build` environment. They start
	// with defaults that keep the builder's own Go configuration out (GOENV=off,
	// empty GOFLAGS, default GOEXPERIMENT and GOFIPS140, GOTOOLCHAIN=local),
	// followed by the recorded settings, which override them.
	Env []string
}

Config is the part of a binary's build configuration that a plugin for it repeats.

func FromBinary

func FromBinary(path string) (Config, error)

FromBinary returns the configuration recorded in the binary at path.

func FromBuildInfo

func FromBuildInfo(info *debug.BuildInfo) (Config, error)

FromBuildInfo returns the configuration recorded in info.

func Running

func Running() (Config, error)

Running returns the configuration of the running binary, e.g. a test binary that loads plugins it builds. It is empty if the binary carries no build information.

Jump to

Keyboard shortcuts

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