#HSLIDE
Gildas Chabot, leboncoin
#HSLIDE
#HSLIDE
dlfcn.h
(dynamic linking) with cgo
#HSLIDE
#HSLIDE
https://github.com/hashicorp/go-plugin https://github.com/natefinch/pie
#HSLIDE
-buildmode=plugin
build option.so
#HSLIDE
Open(path string) (*Plugin, error)
(p *Plugin) Lookup(symName string) (Symbol, error)
Plugin
Symbol
Open
, all new packages have their
init
function calledSee https://tip.golang.org/pkg/plugin/
#HSLIDE
p, err := plugin.Open("plugin.so")
fs, err := p.Lookup("Transform")
f, ok := fs.(func(image.Image) image.Image)
vs, err := p.Lookup("Priority")
v, ok = *vs.(*int)
#HSLIDE
#HSLIDE
.so
file
fatal error: runtime: no plugin module data
panic
during execution#HSLIDE
.so
loaded in Go
#HSLIDE
Questions?
Find the code and slides on Github: https://github.com/GildasCh/go-plugins-demo