#HSLIDE
Hamza AID, Barcelona, Schibsted Media Group
#HSLIDE
#HSLIDE
- Created in 2007, launched in 2009 by Roke pike at Google
- Its not object-oriented programming or functional programming
- Highly strict
- Concurrency
- Native HTTP support
- Highly performante
- Compiled & Cross platform
#HSLIDE
- Cool Package system
- Concurrency: goroutines and channels
- Integrated testing kit
#HSLIDE
#HSLIDE
#HSLIDE
- Decoupling
- Redundancy (Escape the fail)
- Scalability
- Resiliency (Failover easily when infra fails)
- Ordering Guarantees (Maybe FIFO)
- Asynchronous Communication
#HSLIDE
#HSLIDE
#HSLIDE
- Released in 1.8
- Add Go code at runtime
- Works only on linux for now
- Based on C's
dlfcn.h
(dynamic linking) withcgo
#HSLIDE
- Extend a service with third party functions
- Web server
- Media player
- Update behaviour at runtime
#HSLIDE
-
Add plugins at compile time (Caddy)
-
HTTP/RPC calls
-
Check:
#HSLIDE
- Nothing special on the code of the plugin
-buildmode=plugin
build option
- Creates a
.so
#HSLIDE
- Only two functions:
Open(path string) (*Plugin, error)
(p *Plugin) Lookup(symName string) (Symbol, error)
- Two types:
Plugin
Symbol
- When the plugin if first
Open
, all new packages have theirinit
function called
See 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
- Plugin == safe?
- Same rights as caller
- Check the sources of the plugins!
#HSLIDE
- Invalid
.so
filefatal error: runtime: no plugin module data
- Can
panic
during execution
#HSLIDE
- Go plugin used in C
- Already done with -buildmode=shared
- C
.so
loaded in Go- For now, error "no plugin module data"
#HSLIDE
Questions?