You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(lang/go): Revise Go language support section (#311)
* Revise Go language support section
Added more details where necessary. Factored code examples out
into separate files and included them.
Made the "Testing the add component" section consistent
with other examples involving the example host.
* Move WIT example into a separate directory so it doesn't affect the tutorial build
* Update component-model/src/language-support/go.md
Co-authored-by: Victor Adossi <123968127+vados-cosmonic@users.noreply.github.com>
* Clarify what `wit wkg build` does
---------
Co-authored-by: Victor Adossi <123968127+vados-cosmonic@users.noreply.github.com>
Optional: Install the [`wkg`][wkg] CLI tool to resolve the imports in the WIT file. The `wkg` CLI is a part of the [Wasm Component package manager](https://github.com/bytecodealliance/wasm-pkg-tools/releases)
37
+
Optional: Install the [`wkg`][wkg] CLI tool to resolve the imports in the WIT file.
38
+
The `wkg` CLI is a part of the [Wasm Component package manager][wasm-pkg-tools-releases].
39
+
See [the wasm-pkg-tools installation instructions][wasm-pkg-tools] to install manually or using `cargo`.
> **WARNING:** By default, tinygo includes all debug-related information in your .wasm file. That is desirable when prototyping or testing locally to obtain useful backtraces in case of errors (for example, with `wasmtime::WasmBacktraceDetails::Enable`). To remove debug data and optimize your binary file, build with `-no-debug`. The resulting .wasm file will be considerably smaller (up to 75% reduction in size).
278
+
* The `-target=wasip2` flag specifies that the code should be compiled
279
+
to WebAssembly using Preview 2 methods.
280
+
* The `-o adder.wasm` flag directs the output to be saved in `add.wasm` in the current directory.
281
+
* The `--wit-package` flag specifies the package name for the WIT code we are using.
282
+
* The `--wit-world` flag specifies that the WIT world that defines the imports and exports
283
+
for our component is `adder`.
294
284
295
-
We now have an add component that satisfies our `adder` world, exporting the `add` function, which
285
+
We now have an `adder` component that satisfies our `adder` world, exporting the `add` function.
286
+
287
+
> [!WARNING]
288
+
> By default, tinygo includes all debug-related information in your .wasm file.
289
+
> That is desirable when prototyping or testing locally to obtain useful backtraces in case of errors
290
+
> (for example, with `wasmtime::WasmBacktraceDetails::Enable`).
291
+
> To remove debug data and optimize your binary file, build with `-no-debug`.
292
+
> The resulting .wasm file will be considerably smaller (up to 75% reduction in size).
296
293
297
294
We can confirm using the `wasm-tools component wit` command:
298
295
299
296
```console
300
-
$ wasm-tools component wit add.wasm
297
+
$ wasm-tools component wit adder.wasm
301
298
package root:component;
302
299
303
300
world root {
@@ -313,20 +310,20 @@ world root {
313
310
314
311
## 5. Testing the `add` Component
315
312
316
-
To run our add component, we need to use a host program with a WASI runtime that understands the
317
-
`example` world -- we've provided an [`example-host`][example-host] that does just that.
313
+
The following section requires you to have [a Rust toolchain][rust] installed.
318
314
319
-
The example host calls the `add` function of a passed in component providing two operands.
315
+
To run our add component, we need to use a host program with a WASI runtime that understands
316
+
the `example` world.
320
317
321
-
To use the examplehost, clone this repository and run the Rust program:
0 commit comments