Categorygithub.com/belak/go-plugin
modulepackage
0.1.1
Repository: https://github.com/belak/go-plugin.git
Documentation: pkg.go.dev

# README

go-plugin

GoDoc Travis Coveralls

go-plugin is a wrapper around go-resolve which makes it easy to load plugins that depend on each other based on a whitelist and blacklist.

Types of Plugins

There are two types of plugins. Providers and Optional plugins.

Providers are always loaded by the system, regardless of the whitelist/blacklist. They can still take arguments, even from optional plugins.

Optional plugins are loaded based on the whitelist/blacklist.

Plugin Requirements

Each plugin needs to be a function which runs the code to load that plugin. Any type in the method signature will be handled using injection. Any returned error will halt plugin loading and return that error from Registry.Load.

Important Dependencies

go-resolve does most of the heavy lifting by running a topological sort of all the plugins so they're loaded in the proper order. It relies on inject to do the reflection work to actually load the plugins.

glob is used in the whitelist and blacklist to determine which plugins should be loaded. There are a few tricks with the glob syntax, so be sure to look here if you're having trouble.

# Functions

Ensure is a simple wrapper which will panic if the given error is non-nil.
NewRegistry creates a new empty Registry.

# Structs

Registry represents a group of plugins which can be loaded.