-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (35 loc) · 862 Bytes
/
main.go
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
//go:build js && wasm
package main
import (
"fmt"
"syscall/js"
"github.com/chumaumenze/gastly/lib/objects"
"github.com/chumaumenze/gjs"
)
func main() {
gastly := js.ValueOf(map[string]any{
"ping": js.FuncOf(func(this js.Value, args []js.Value) any {
return gjs.ValueOf("pong!").Into()
}),
"FromSourceCode": js.FuncOf(objects.FromSourceCode),
"FromPackages": js.FuncOf(objects.FromPackages),
})
js.Global().Set("Gastly", gastly)
for {
quitChannel := make(chan *struct{})
func() {
defer func() {
if v := recover(); v != nil {
fmt.Printf("PANIC caught: %s\n", v)
}
}()
println("This is GASTly Renderer")
// block until interrupt/terminate signal
if terminate := <-quitChannel; terminate != nil {
fmt.Println("Goodbye from Gastly!")
}
fmt.Println("Recovering from panic...")
return
}()
}
}