ref: d56b73e947b256be7d2da8c2b0d199a405d1dcf0
parent: f12cae5a08bf674fa1daa8e2d509c3e0eba2e1db
author: Skyrbunny <[email protected]>
date: Wed Jun 28 10:58:15 EDT 2023
reading files now instead of embedding
binary files a/ricket b/ricket differ
--- a/ricket.go
+++ b/ricket.go
@@ -11,9 +11,6 @@
"github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1"
)
-//go:embed test.wasm
-var guestWasm []byte
-
func main() {
ctx := context.Background()
@@ -23,6 +20,12 @@
wasi_snapshot_preview1.MustInstantiate(ctx, r)
+ // Read program
+ wasm, err := os.ReadFile(os.Args[1])
+ if err != nil {
+ log.Panicf("failed to read WASM file: %v", err)
+ }
+
// Run program
conf := wazero.NewModuleConfig().
WithStdout(os.Stdout).
@@ -34,7 +37,7 @@
WithFSConfig(wazero.NewFSConfig()).
WithRandSource(rand.Reader)
- _, err := r.InstantiateWithConfig(ctx, guestWasm, conf)
+ _, err = r.InstantiateWithConfig(ctx, wasm, conf)
if err != nil {
log.Panicf("failed to instantiate WASM program: %v", err)
}