wa-lang.org/wazero@v1.0.2/examples/namespace/README.md (about)

     1  ## Stateful import example
     2  
     3  This example shows how WebAssembly modules can import their own stateful host
     4  module, such as "env", in the same runtime.
     5  
     6  ```bash
     7  $ go run counter.go
     8  ns1 count=0
     9  ns2 count=0
    10  ns1 count=1
    11  ns2 count=1
    12  ```
    13  
    14  Specifically, each WebAssembly-defined module is instantiated alongside its own
    15  Go-defined "env" module in a separate `wazero.Namespace`. This is more
    16  efficient than separate runtimes as instantiation re-uses the same compilation
    17  cache.