-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.go
More file actions
42 lines (38 loc) · 842 Bytes
/
plugin.go
File metadata and controls
42 lines (38 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"log"
"net/http"
"plugin"
"time"
_ "net/http/pprof"
"os"
"os/signal"
"syscall"
)
func main() {
go func() {
log.Println(http.ListenAndServe(":6060", nil))
}()
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGTERM)
go func() {
println(">>>>>>>>>>>>>>>>>>>>>>>>>>>Notify")
<-sc
println(">>>>>>>>>>>>>>>>>>>>>>>>>>>Stopping")
os.Exit(1)
}()
for {
p, _ := plugin.Open("./plugin/myplugin.so")
add, _ := p.Lookup("Add")
editHandlerOk, _ := p.Lookup("EditHandlerOk")
addFunc := add.(func(int, int) int)
println(addFunc(1, 2))
println(addFunc(2, 2))
http.HandleFunc("/", editHandlerOk.(func(http.ResponseWriter, *http.Request)))
if err := http.ListenAndServe(":8181", nil); err != nil {
log.Fatal(err.Error())
}
time.Sleep(1 * time.Second)
println("Serving")
}
}