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
+55-5Lines changed: 55 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -296,11 +296,61 @@ e.g. Java, Kotlin, Clojure, Scala, etc.
296
296
297
297
### Guest: TinyGo
298
298
299
-
The Go language currently can be compiled to standalone out-of-browser
300
-
WebAssembly binaries using the [TinyGo](https://tinygo.org/) toolchain.
301
-
Support does not yet exist in this repository for TinyGo but is being worked on
302
-
[in a PR](https://github.com/bytecodealliance/wit-bindgen/pull/321) and is
303
-
expected to land in this repository at some point in the future.
299
+
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:
300
+
301
+
`tinygo build -target -target=wasi main.go`
302
+
303
+
> Note: the current TinyGo bindgen only supports TinyGo version v0.27.0 or later.
304
+
305
+
To start in Go a `*.go` and `*.h` C header file are generated for your
306
+
project to use. These files are generated with the [`wit-bindgen` CLI
307
+
command][cli-install] in this repository.
308
+
309
+
```sh
310
+
wit-bindgen tiny-go ./wit
311
+
# Generating "host.go"
312
+
# Generating "host.c"
313
+
# Generating "host.h"
314
+
# Generating "host_component_type.o"
315
+
```
316
+
317
+
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.
0 commit comments