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
Copy file name to clipboardExpand all lines: README.md
+17-12Lines changed: 17 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -320,15 +320,13 @@ e.g. Java, Kotlin, Clojure, Scala, etc.
320
320
321
321
### Guest: TinyGo
322
322
323
-
Go code can be compiled for the `wasm32-wasi` target using the [TinyGo](https://tinygo.org/) compiler. For example, the following command compiles `main.go` to a wasm modules with WASI support:
323
+
You can compile Go code into a Wasm module using the [TinyGo](https://tinygo.org/) compiler. For example, the following command compiles `main.go` to a WASI module:
324
324
325
325
`tinygo build -target=wasi main.go`
326
326
327
-
> Note: the current TinyGo bindgen only supports TinyGo version v0.27.0 or later.
327
+
> Note: the current TinyGo `bindgen` requires TinyGo version v0.27.0 or later.
328
328
329
-
To start in Go a `*.go` and `*.h` C header file are generated for your
330
-
project to use. These files are generated with the [`wit-bindgen` CLI
331
-
command][cli-install] in this repository.
329
+
When using `wit-bindgen tiny-go` bindgen, `*.go` and `*.h` C header file are generated for your project. These files are generated with the [`wit-bindgen` CLI command][cli-install] in this repository.
332
330
333
331
```sh
334
332
wit-bindgen tiny-go ./wit
@@ -338,35 +336,42 @@ wit-bindgen tiny-go ./wit
338
336
# Generating "host_component_type.o"
339
337
```
340
338
341
-
If your Go code uses `result` or `option` type, a second Go file `host_types.go` will be generated. This file contains the Go types that correspond to the `result` and `option` types in the WIT file.
339
+
If your Go code uses `result` or `option` type, an additional Go file `host_types.go` will be generated. This file contains the Go types that correspond to the `result` and `option` types in the WIT file.
342
340
343
-
Some example code using this would then look like
341
+
An example of using the generated Go code would look like:
This can then be compiled with `tinygo` and assembled into a component with:
374
+
This setup allows you to invoke `go generate`, which generates the bindings for the Go code into an `api` directory. Afterward, you can compile your Go code into a WASI module using the TinyGo compiler. Lastly you can componentize the module using `wasm-tools`:
0 commit comments