MZ How to write a wasm plugin

Hey a friend of me is askingif I could develop a plugin for him. But since I'm a Go developer I was wondering if it would be possible to create a wasm plugin.

But I didn't find a way, to load my wasm file within the PRG maker runtime.

In the golang wiki is written, that I need to include a JS file as a glue between the wasm file & JS:
Golang Wiki -> https://github.com/golang/go/wiki/WebAssembly
Include JS file -> wasm_exec.js

And to use the Golang functions from wasm it should be something like this:

const go = new Go(); WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then((result) => { go.run(result.instance); });

When I add the wasm_exec.js file as a plugin and a try to load the wasm file in other JS file it only works in the Browser.

Screenshot 2021-09-18 at 16.22.32.png


But it doesn't matter what I tried to include the wasm_exec.js file, it will always say that Go is not defined.

Screenshot 2021-09-18 at 15.34.53.png


Is there some tutorial how to do this?

Thanks for any help 🙂
Moved to: Learning Javascript

I'd ditch Go completely and just use javascript.
if it works in the browser but not on PC, I imagine its because your working directory is different on each one. Try to verify relative path.

I believe that, on a browser, because your main page is the index.html that its directory will be the working directory(or root). For desktop, it may be where the Game.exe is located

Original thread: https://forums.rpgmakerweb.com/threads/how-to-write-a-wasm-plugin.140557/