Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/letiantech/hotplugin
golang plugin framework for hot update
https://github.com/letiantech/hotplugin
framework golang golang-library hot-update plugin
Last synced: 2 months ago
JSON representation
golang plugin framework for hot update
- Host: GitHub
- URL: https://github.com/letiantech/hotplugin
- Owner: letiantech
- License: mit
- Created: 2017-07-04T16:05:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-01-08T12:58:49.000Z (about 3 years ago)
- Last Synced: 2024-08-01T13:30:34.636Z (5 months ago)
- Topics: framework, golang, golang-library, hot-update, plugin
- Language: Go
- Size: 21.5 KB
- Stars: 39
- Watchers: 7
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ccamel - letiantech/hotplugin - golang plugin framework for hot update (Go)
README
[![Build Status](https://travis-ci.org/letiantech/hotplugin.svg)](https://travis-ci.org/letiantech/hotplugin)
# hotplugin
golang plugin framework for hot update, go version >= 1.8# usage
1. get hotplugin
```bash
go get github.com/letiantech/hotplugin
```
2. write a plugin with Load, Unload and other functions like this
```go
//testplugin.go
package mainimport (
"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
}
```3. build your plugin
```bash
go build -buildmode=plugin ./testplugin.go
```4. save your testplugin.so to /path/of/plugin/dir
5. write main.go like this
```go
//main.go
package mainimport (
"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...)
}```