GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - letiantech/hotplugin: golang plugin framework for hot update

BranchesTags
Open more actions menu

Latest commit

 

History

20 Commits
20 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/ISSUE_TEMPLATE
.github/ISSUE_TEMPLATE
 
 
example
example
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
hotplugin.go
hotplugin.go
 
 
manager.go
manager.go
 
 
plugin.go
plugin.go
 
 

Repository files navigation

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...)
}

About

golang plugin framework for hot update

Topics

frameworkgolanggolang-libraryhot-updateplugin

Resources

Readme
MIT license
Activity
Custom properties

Stars

38 stars

Watchers

6 watching

Forks

4 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.