Skip to content

Instantly share code, notes, and snippets.

@jeremywho
Created December 5, 2016 20:23
Show Gist options
  • Save jeremywho/e59501056efca467c996e7aac311dc84 to your computer and use it in GitHub Desktop.
Save jeremywho/e59501056efca467c996e7aac311dc84 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"plugin"
)
func main() {
p, _ := plugin.Open("./myplugin.so")
add, _ := p.Lookup("Add")
sum := add.(func(int, int) int)(1, 2)
fmt.Println(sum)
}
package main
func Add(x, y int) int {
return x+y
}
@GrimTheReaper
Copy link

GrimTheReaper commented Dec 5, 2016

func panicOnError(err error) {
  if err != nil {
    panic(err)
  }
}

You should handle errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment