extensibility

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package extensibility dynamically loads external Go plugins using `LoadPlugin`. Just provide a symbol name (e.g., a function) to integrate new features on-the-fly—no rebuilds or redeploys required.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadPlugin

func LoadPlugin[T any](path string, symName string) (T, error)

LoadPlugin loads a plugin from the given path and returns the symbol with the given name.

Example

This example has no Output comment: it needs a plugin built beside it.

package main

import (
	"fmt"
	"log"

	"github.com/andygeiss/cloud-native-utils/extensibility"
)

func main() {
	// The plugin is built separately, by the same toolchain as this program:
	//
	//	go build -buildmode=plugin -o adapter.so adapter.go
	//
	// The consumer declares the interface it wants back, so the plugin never
	// has to import this package.
	type Repository interface {
		FindByID(id string) (name string, err error)
	}

	adapter, err := extensibility.LoadPlugin[Repository]("adapter.so", "Adapter")
	if err != nil {
		log.Fatal(err)
	}

	name, err := adapter.FindByID("1")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(name)
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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