Package pluginunmarshal unmarshals Go plugins into structs.
Go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.travis.yml
LICENSE
README.md
pluginunmarshal.go
pluginunmarshal_test.go

README.md

pluginunmarshal Build Status GoDoc

Package pluginunmarshal unmarshals Go plugins into structs.

// Assume pathToPlugin refers to a Go plugin file compiled from this code:
//
//   package main
//
//   var Hello = "Hello from a plugin!"
//
//   func Add(a, b int) int {
//      return a + b
//   }
//

var v struct {
    Add     func(a, b int) int
    MyHello string `plugin:"Hello"`
    Ignored bool   `plugin:"-"`
}

err := pluginunmarshal.Open(pathToPlugin, &v)
if err != nil {
    panic(err)
}

fmt.Println(v.Add(2, 3))
fmt.Println(v.MyHello)
// Output:
// 5
// Hello from a plugin!

See the docs for more.