Author: techfox9

Building and using a plugin in Go / Golang

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]

. . .



Five latest

Building and using a plugin in Go / Golang

Jan 15, 2020 by techfox9 in GoLang

openssl common commands

Sep 21, 2017 by techfox9 in Uncategorized

postgres notes 2 ..

Jan 28, 2016 by techfox9 in Database, PostgreSQL

Basic REST web service example ..

May 08, 2015 by techfox9 in Java, REST, Web, WebServices

node.js learning with learnyounode .. solutions ..

May 08, 2015 by techfox9 in javascript, node.js