A comparision of go plugin package and other plugin implementations for Go.
Following packages have been used:
- hashicorp go-plugin (via gRPC)
- pie plugin: (via rpc)
- Native Go plugin
Benchmarking
Each plugin framework has been used to build Key/Value store CLI where mechanism for storing and retrieving keys is pluggable.
- Building hashicorp go-plugin
$ cd hashicorp-go-plugin
# Build the main CLI
$ go build -o kv
# build the grpc plugin
$ go build -o kv-go-grpc ./plugin
# This tells the KV binary to use the "kv-go-grpc" binary
$ export KV_PLUGIN="./kv-go-grpc"
# Read and write
$ ./kv put hello world
$ ./kv get hello
world
- Building pie go plugin
$ cd pie-plugin
$ cd plugin_provider
# Build the plugin
$ go build -o plugin_provider
# Add the binary to $PATH or move the binary to master_provider
$ export PATH="path/to/plugin_provider:$PATH"
$ cd ../master_provider
# run the master
$ go run main.go
- Native Go plugin
$ cd native-go-plugin
# Build the plugin
$ go build -buildmode=plugin -o kv.so
# Run main.go
$ go run ../main.go