Created
December 2, 2016 11:50
-
-
Save kron4eg/fdf2e8ad81e5e985f8f62ff8f1b01571 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"plugin" | |
"plugs/shared" | |
) | |
func main() { | |
p, err := plugin.Open("plug1.so") | |
if err != nil { | |
panic(err) | |
} | |
f, err := p.Lookup("Print") | |
if err != nil { | |
panic(err) | |
} | |
prnt, ok := f.(func(*shared.Struct)) | |
if !ok { | |
panic("unknown signature") | |
} | |
s := shared.NewStruct() | |
go prnt(s) | |
fmt.Println(<-s.Ch1) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"plugs/shared" | |
) | |
func init() { | |
fmt.Println("plugin init") | |
} | |
func Print(s *shared.Struct) { | |
// fmt.Printf("%#v", s) | |
s.Ch1 <- 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment