All Projects → letiantech → hotplugin

letiantech / hotplugin

Licence: MIT License
golang plugin framework for hot update

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to hotplugin

flutter dynamic
The flutter_dynamic is a library that create flutter application dynamic.
Stars: ✭ 66 (+135.71%)
Mutual labels:  hot-update
Faygo
Faygo is a fast and concise Go Web framework that can be used to develop high-performance web app(especially API) with fewer codes. Just define a struct handler, faygo will automatically bind/verify the request parameters and generate the online API doc.
Stars: ✭ 1,557 (+5460.71%)
Mutual labels:  hot-update

Build Status

hotplugin

golang plugin framework for hot update, go version >= 1.8

usage

  1. get hotplugin
go get github.com/letiantech/hotplugin
  1. write a plugin with Load, Unload and other functions like this
//testplugin.go
package main

import (
	"fmt"
	"log"
)

const (
	pluginName    = "testplugin"
	pluginVersion = 0x00010000
)

func Load(register func(name string, version uint64) error) error {
	err := register(pluginName, pluginVersion)
	if err != nil {
		log.Println(err.Error())
		return err
	}
	log.Println("loading test plugin")
	return nil
}

func Unload() error {
	fmt.Printf("unload %s, version: 0x%x\n", pluginName, pluginVersion)
	return nil
}

func Test(data string) string {
	return "hello " + data
}
  1. build your plugin
go build -buildmode=plugin ./testplugin.go
  1. save your testplugin.so to /path/of/plugin/dir

  2. write main.go like this

//main.go
package main

import (
	"fmt"
	"github.com/letiantech/hotplugin"
)

func main() {
	options := hotplugin.ManagerOptions{
		Dir:    "./",
		Suffix: ".so",
	}
	hotplugin.StartManager(options)
	result := hotplugin.Call("testplugin", "Test", "my world")
	fmt.Println(result...)
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].