charlylib

package
v0.2026287.2154 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 6 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 charlylib is the generic, plugin-AGNOSTIC multi-call host for out-of-process charly plugins.

A charly plugin's cmd/serve is a one-liner: sdk.Main(NewProvider(), NewMeta(), CliMain). Built one-per-plugin, every such binary statically links the whole shared SDK/spec transport closure — and because Go has no runtime shared library for this (buildmode=shared needs cgo + a writable GOROOT and fails across module roots; buildmode=plugin needs cgo and in-process loading), N plugin binaries store that closure N times.

charlylib removes the duplication by hosting MANY plugins in ONE binary: it links the shared closure once and dispatches to the plugin named by the base name it was invoked as (argv[0]). A package installs `plugin-<word>` as a symlink to the single shared `charly-lib` binary, so the loader contract — a `.providers` word manifest beside an executable named `plugin-<word>` — is byte-for-byte unchanged (charly's bakedPluginDirs / discoverBakedPluginWords keep working with ZERO core changes).

This package names NO plugin and imports NO plugin module: the registry is supplied by GENERATED code (charly-lib-gen) built from a data list, so any current or future plugin joins the shared host by being listed, not by editing this library. It depends only on the spec contract module (proto + transport).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(reg Registry)

Run dispatches to the plugin named by filepath.Base(os.Args[0]) and delegates to transport.Main, which decides serve-vs-CLI mode from the go-plugin handshake cookie — identical behaviour to the per-plugin binary it replaces.

A base name absent from the registry, or registered with a nil field, is a hard error (exit 2) naming the problem and the known plugins, so a mis-installed symlink or a bad generated registry fails loudly instead of silently doing nothing (or nil-panicking).

Types

type Plugin

type Plugin struct {
	// Provider constructs the plugin's pb.ProviderServer.
	Provider func() pb.ProviderServer
	// Meta constructs the plugin's pb.PluginMetaServer.
	Meta func() pb.PluginMetaServer
	// CLI runs the plugin's command-mode work with os.Args[1:]; its int return is
	// the process exit code.
	CLI func(args []string) int
}

Plugin is one welded plugin a shared host binary serves. Its three fields are exactly the arguments of a per-plugin cmd/serve's sdk.Main call.

type Registry

type Registry map[string]Plugin

Registry maps a plugin's binary base name (e.g. "plugin-clean") to its Plugin.

func (Registry) Names

func (r Registry) Names() []string

Names returns the registered binary base names, sorted (diagnostics + tests).

Jump to

Keyboard shortcuts

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