Add Go language guide#77
Conversation
|
Currently debugging why the resultant |
|
updating wasmtime version did the trick so this is ready for review |
itowlson
left a comment
There was a problem hiding this comment.
Thanks for doing this! The spine of it is great, but reading it I sometimes felt a bit adrift. Key suggestions would be:
- A bit more of a roadmap up front. We can't go directly from busting out some Go to having a component, so here are the waypoints we're going to hit.
- A bit more what and why, around things like the
init,SetExamplestuff.
But the core story is great! So good to have this in here.
| @@ -0,0 +1,89 @@ | |||
| # Go Tooling | |||
There was a problem hiding this comment.
The comment on the PR mentions you needed Wasmtime 13 for this to work. Should we state that on this section, or wait for #78 to land and rev the entire book to a Wasmtime 13-compatible toolchain? (Are there other tools will not work with Wasmtime 13 though? I am not sure what the alignment status is now the Wasmcon freeze is over.)
There was a problem hiding this comment.
I think a full book rev makes sense. I think it is better than leaving at "latest dev" since that already implies Wasmtime 13 changes
| wit-bindgen tiny-go ./add.wit -w example --out-dir=gen | ||
| ``` | ||
|
|
||
| Now, we can implement the generated `SetExample` type (in `gen/example.go`) that is exported by our component: |
There was a problem hiding this comment.
Is SetExample a name that wit-bindgen creates from... the -w parameter? I'm not quite sure what is happening here.
|
|
||
| func init() { | ||
| a := AddImpl{} | ||
| SetExample(a) |
There was a problem hiding this comment.
Oh! I see! (I think.) This is a gadget wit-bindgen gives us for working around the main problem - it's like for registering your interface implementations in a reactor scenario. Something like that?
There was a problem hiding this comment.
The reasoning behind using init() is to register user implementation as exported interfaces / functions.
| ```go | ||
| package main | ||
|
|
||
| //go:generate wit-bindgen tiny-go ./add.wit -w example --out-dir=gen |
There was a problem hiding this comment.
This looks like the line we just ran. What is its role here?
There was a problem hiding this comment.
This informs go generate what to run, so for future WIT changes, just go generate needs to be run rather than the explicit wit-bindgen command. But it probably over complicates so ill remove
0dfdd32 to
bb3dd4f
Compare
Mossaka
left a comment
There was a problem hiding this comment.
This looks great to me! Thank you for your work @kate-goldenring
|
@kate-goldenring what's the state of this PR? Looks like at the very least it needs a rebase. |
Signed-off-by: Kate Goldenring <kate.goldenring@fermyon.com>
Signed-off-by: Kate Goldenring <kate.goldenring@fermyon.com>
bb3dd4f to
b023afc
Compare
|
@itowlson do you mind giving this another review? I broke the guide up into two sections:
|
…nterface Signed-off-by: Kate Goldenring <kate.goldenring@fermyon.com>
b023afc to
6612cbc
Compare
itowlson
left a comment
There was a problem hiding this comment.
Couple of things to sanity-check but looks good!
| 3. Convert the Wasm core module to a component using | ||
| []`wasm-tools`](https://github.com/bytecodealliance/wasm-tools) | ||
|
|
||
| The next section will walk through steps 1-2, producing a core Wasm module that targets WASI preview 1. |
There was a problem hiding this comment.
Should we line up the ordering here - this next section is actually step 2 not step 1 I think?
There was a problem hiding this comment.
I updated the guide to number the headings and added a section introducing the example world. What do you think? 2be771c
Signed-off-by: Kate Goldenring <kate.goldenring@fermyon.com>
itowlson
left a comment
There was a problem hiding this comment.
This is great - thank you Kate!
Add go language guide and a description of reactor vs command components as a lot of tooling refers to the two but we haven't explicitly called out the difference anywhere
fixes #37