1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 13:00:36 -05:00
denoland-deno/main.go
2018-05-14 00:31:48 -04:00

46 lines
825 B
Go

package main
//go:generate protoc --go_out=. msg.proto
//go:generate ./node_modules/.bin/parcel build --out-dir=dist/ --no-minify main.ts
//go:generate go-bindata -pkg $GOPACKAGE -o assets.go dist/
import (
"github.com/golang/protobuf/proto"
"github.com/ry/v8worker2"
"os"
)
func recv(msg []byte) []byte {
println("recv cb", string(msg))
return nil
}
func loadAsset(w *v8worker2.Worker, path string) {
data, err := Asset(path)
if err != nil {
panic("asset not found")
}
err = w.Load(path, string(data))
if err != nil {
panic(err)
}
}
func main() {
worker := v8worker2.New(recv)
loadAsset(worker, "dist/main.js")
loadMsg := &Msg{
Kind: Msg_LOAD,
Argv: os.Args,
}
out, err := proto.Marshal(loadMsg)
if err != nil {
panic(err)
}
err = worker.SendBytes(out)
if err != nil {
panic(err)
}
}