Building and using a plugin in Go / Golang
Jan 15, 2020 by techfox9 in GoLang
Author: techfox9
Jan 15, 2020 in GoLang
From https://medium.com/quick-code/write-a-web-service-with-go-plug-ins-c0472e0645e6
The plugin module (pluginex1.go):
[java]
package main
import “fmt”
func Talk() {
fmt.Println(“Hello From Plugin !”)
}
[/java]
Build the plugin module:
[java]
# go build -buildmode=plugin -o pluginex1.so pluginex1.go
[/java]
Invoke the plugin module (pluginex1main.go):
[java]
package main
import(
“os”
“fmt”
“plugin”
)
func main() {
plugin, err := plugin.Open(“pluginex1.so”)
if err != nil {
fmt.Println(err)
os.Exit(-1)
}
sym, err := plugin.Lookup(“Talk”) // reflection
if err != nil {
fmt.Println(err)
os.Exit(-1)
}
sym.(func())()
}
[/java]
. . .
Jan 15, 2020 by techfox9 in GoLang
Sep 21, 2017 by techfox9 in Uncategorized
Jan 28, 2016 by techfox9 in Database, PostgreSQL
May 08, 2015 by techfox9 in Java, REST, Web, WebServices
May 08, 2015 by techfox9 in javascript, node.js