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 ¶
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 ¶
FromBinary returns the configuration recorded in the binary at path.
func FromBuildInfo ¶
FromBuildInfo returns the configuration recorded in info.