shithub: ricket

Download patch

ref: f12cae5a08bf674fa1daa8e2d509c3e0eba2e1db
author: Skyrbunny <tallesttower1@gmail.com>
date: Tue Jun 27 22:13:26 EDT 2023

init

--- /dev/null
+++ b/go.mod
@@ -1,0 +1,5 @@
+module ricket
+
+go 1.19
+
+require github.com/tetratelabs/wazero v1.2.1 // indirect
--- /dev/null
+++ b/go.sum
@@ -1,0 +1,2 @@
+github.com/tetratelabs/wazero v1.2.1 h1:J4X2hrGzJvt+wqltuvcSjHQ7ujQxA9gb6PeMs4qlUWs=
+github.com/tetratelabs/wazero v1.2.1/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ=
binary files /dev/null b/ricket differ
--- /dev/null
+++ b/ricket.go
@@ -1,0 +1,41 @@
+package main
+
+import (
+	"context"
+	"crypto/rand"
+	_ "embed"
+	"log"
+	"os"
+
+	"github.com/tetratelabs/wazero"
+	"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
+)
+
+//go:embed test.wasm
+var guestWasm []byte
+
+func main() {
+	ctx := context.Background()
+
+	// Instantiate runtime
+	r := wazero.NewRuntimeWithConfig(ctx, wazero.NewRuntimeConfigInterpreter())
+	defer r.Close(ctx)
+
+	wasi_snapshot_preview1.MustInstantiate(ctx, r)
+
+	// Run program
+	conf := wazero.NewModuleConfig().
+		WithStdout(os.Stdout).
+		WithStderr(os.Stderr).
+		WithStdin(os.Stdin).
+		WithSysNanosleep().
+		WithSysNanotime().
+		WithSysWalltime().
+		WithFSConfig(wazero.NewFSConfig()).
+		WithRandSource(rand.Reader)
+
+	_, err := r.InstantiateWithConfig(ctx, guestWasm, conf)
+	if err != nil {
+		log.Panicf("failed to instantiate WASM program: %v", err)
+	}
+}
binary files /dev/null b/test.wasm differ