summaryrefslogtreecommitdiff
path: root/main.go
blob: b3a3e8874d854cee39ab309f30b884655c06f77c (plain)
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
// To test: make && ./out/render test_input.js
package main

//go:generate go-bindata -pkg $GOPACKAGE -o assets.go dist/

import (
	"github.com/ry/v8worker2"
)

func recv(msg []byte) []byte {
	println("recv cb", string(msg))
	return nil
}

func main() {
	indexFn := "dist/main.js"
	data, err := Asset(indexFn)
	if err != nil {
		panic("asset not found")
	}
	code := string(data)

	worker := v8worker2.New(recv)

	// Load up index.js code.
	err = worker.Load(indexFn, code)
	if err != nil {
		println("Problem executing Javascript.")
		panic(err)
	}
}