Build a plugin
go build -buildmode=plugin -o hello.so hello.go
pluginLoad Go shared objects (.so) at runtime. Linux/macOS only. Fragile — all plugins must match the host's exact toolchain and deps. Rarely the right tool.
go build -buildmode=plugin -o hello.so hello.go
p, err := plugin.Open("hello.so")
if err != nil { log.Fatal(err) }
sym, err := p.Lookup("Greet")
if err != nil { log.Fatal(err) }
greet := sym.(func(string) string)
fmt.Println(greet("world"))