Skip to content

Package pluginunmarshal unmarshals Go plugins into structs.

License

Notifications You must be signed in to change notification settings

tcard/pluginunmarshal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Package pluginunmarshal unmarshals Go plugins into structs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages