go-plugin-tryout

command module
v0.0.0-...-6631669 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: Unlicense Imports: 5 Imported by: 0

README

go-plugin-tryout

trying out plugin mechanisms:

on windows, run:

demo.bat

on *X:

./demo.sh

Plugin Approaches Comparison

hashicorp/go-plugin (RPC-based)

Pros:

  • Cross-platform: Works on all platforms (Windows, Linux, macOS)
  • Process isolation: Plugins run in separate processes, providing better isolation and crash protection
  • Version flexibility: Can work with different Go versions between host and plugin
  • Network support: Can run plugins over network
  • Better error handling: Process crashes don't affect the main application

Cons:

  • Performance overhead: RPC communication adds latency compared to in-process calls
  • Resource usage: Each plugin runs as a separate process
  • Complexity: Requires more boilerplate code (RPC wrappers, handshake configs)
  • Startup time: Process spawning adds initialization overhead
golang.org/pkg/plugin (Native)

Pros:

  • Performance: Direct in-process calls, no RPC overhead
  • Low latency: Function calls are as fast as regular Go function calls
  • Resource efficiency: Shared memory space, no separate processes
  • Simplicity: Simpler API, less boilerplate code

Cons:

  • Platform limitations: NOT supported on Windows/amd64 (see demo.bat line 15)
  • Go version lock: Plugin and host must be compiled with the same Go version
  • No isolation: Plugin crashes can bring down the main application
  • Build constraints: Requires -buildmode=plugin flag and platform-specific file extensions (.so, .dylib)
Platform Support Summary
Platform hashicorp/go-plugin golang.org/pkg/plugin
Linux
macOS
Windows ❌ (not supported)

Structure

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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