From 3b6ae3b64004f6e529789e36f77b938e2ebca278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 5 Aug 2024 18:43:15 +0200 Subject: [PATCH] Improve ImportResolver example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compile once and reuse. See #2294 Signed-off-by: Bjørn Erik Pedersen --- experimental/importresolver_example_test.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/experimental/importresolver_example_test.go b/experimental/importresolver_example_test.go index 3c48212f0d..10b3dc8a81 100644 --- a/experimental/importresolver_example_test.go +++ b/experimental/importresolver_example_test.go @@ -43,19 +43,20 @@ func Example_importResolver() { wasi_snapshot_preview1.MustInstantiate(ctx, r) + idm, err := r.CompileModule(ctx, inoutdispatcherWasm) + if err != nil { + log.Panicln(err) + } + idcm, err := r.CompileModule(ctx, inoutdispatcherclientWasm) + if err != nil { + log.Panicln(err) + } + const numInstances = 3 mods := make([]*mod, numInstances) for i := range mods { mods[i] = &mod{} m := mods[i] - idm, err := r.CompileModule(ctx, inoutdispatcherWasm) - if err != nil { - log.Panicln(err) - } - idcm, err := r.CompileModule(ctx, inoutdispatcherclientWasm) - if err != nil { - log.Panicln(err) - } const inoutDispatcherModuleName = "inoutdispatcher"