Closed deadprogram closed 4 months ago
With this change you can now do this:
println("Loading and running WASM code...")
ins, err := eng.LoadAndRun(bytes.NewReader(wasmCode))
if err != nil {
println(err.Error())
return
}
instead of always having to do this:
println("Loading WASM module...")
if err := eng.Interpreter.Load(bytes.NewReader(wasmModule)); err != nil {
println(err.Error())
return
}
println("Running module...")
ins, err := eng.Interpreter.Run()
if err != nil {
println(err.Error())
return
}
Based on side-channel conversation with @orsinium we will also do some additional work in future PR to better scope Interpreter
and Module
for the individual Load()
and Run()
methods respectively.
Now merging.
This PR adds a
LoadAndRun()
method to the engine to reduce the boilerplate needed code to support the most typical usage.