Skip to content

Commit a9aa88a

Browse files
committed
README: spring cleaning
1 parent 7046cb8 commit a9aa88a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,17 @@ Package `wit/bindgen` contains code to generate Go bindings for [Component Model
1212

1313
Package `cm` contains helper types and functions used by generated packages, such as `option<t>`, `result<ok, err>`, `variant`, `list`, and `resource`. These are intended for use by generated [Component Model](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#type-definitions) bindings, where the caller converts to a Go equivalent. It attempts to map WIT semantics to their equivalent in Go where possible.
1414

15-
#### Note on Memory Safety
16-
17-
Package `cm` and generated bindings from `wit-bindgen-go` may have compatibility issues with the Go garbage collector, as they directly represent `variant` and `result` types as tagged unions where a pointer shape may be occupied by a non-pointer value. The GC may detect and throw an error if it detects a non-pointer value in an area it expects to see a pointer. This is an area of active development.
18-
1915
## `wit-bindgen-go`
2016

2117
### WIT → Go
2218

23-
The `wit-bindgen-go` tool can generate Go bindings for WIT interfaces and worlds. If [`wasm-tools`](https://crates.io/crates/wasm-tools) is installed and in `$PATH`, then `wit-bindgen-go` can load WIT directly.
19+
`wit-bindgen-go` generates Go bindings for WIT interfaces and worlds. It generates a Go package for each WIT world and interface, with the necessary types, functions, methods, and ABI glue code. Generated code will depend on package `cm` for core Component Model types like `list<t>`.
2420

2521
```console
2622
wit-bindgen-go generate ../wasi-cli/wit
2723
```
2824

29-
Otherwise, pass the JSON representation of a fully-resolved WIT package:
25+
It also supports the [JSON representation](https://github.com/bytecodealliance/wasm-tools/pull/1203) of a fully-resolved WIT package:
3026

3127
```console
3228
wit-bindgen-go generate wasi-cli.wit.json
@@ -60,6 +56,10 @@ This will emit JSON on `stdout`, which can be piped to a file or another program
6056
wasm-tools component wit -j --all-features example.wit > example.wit.json
6157
```
6258

59+
## Memory Safety and Garbage Collection
60+
61+
Package `cm` and generated bindings from `wit-bindgen-go` may have compatibility issues with the Go garbage collector. This is due to the memory representation of `variant` and `result` types as tagged unions where a pointer shape may be occupied by a non-pointer value. In Go (but not TinyGo), the GC may detect and throw an error if it detects a non-pointer value in an area it expects to see a pointer. This is an area of active development.
62+
6363
## License
6464

6565
This project is licensed under the Apache 2.0 license with the LLVM exception. See [LICENSE](LICENSE) for more details.

0 commit comments

Comments
 (0)