-
Notifications
You must be signed in to change notification settings - Fork 79
Revise Go language support section #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vados-cosmonic
merged 4 commits into
bytecodealliance:main
from
catamorphism:language-support-go
Sep 9, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a5ff1f5
Revise Go language support section
catamorphism 9add2d3
Move WIT example into a separate directory so it doesn't affect the t…
catamorphism f033734
Update component-model/src/language-support/go.md
catamorphism b55054c
Clarify what `wit wkg build` does
catamorphism File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| //go:generate go tool wit-bindgen-go generate --world adder --out internal ./docs:adder@0.1.0.wasm | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "example.com/internal/docs/adder/add" | ||
| ) | ||
|
|
||
| func init() { | ||
| add.Exports.Add = func(x uint32, y uint32) uint32 { | ||
| return x + y | ||
| } | ||
| } | ||
|
|
||
| // main is required for the `wasi` target, even if it isn't used. | ||
| func main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package docs:adder@0.1.0; | ||
|
|
||
| interface add { | ||
| add: func(x: u32, y: u32) -> u32; | ||
| } | ||
|
|
||
| world adder { | ||
| include wasi:cli/imports@0.2.0; | ||
|
|
||
| export add; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The title of this section says it's about "resolve and download imports" so as a reader I have questions about why I am doing this encoding malarkey. After all, "resolve and download" is what
fetchdoes, so why am I not doing that?Looking ahead to section 3, I am guessing it is something like: in order to use
go tool wit-bindgen-go, we must have a package (that is addressable using package notation) rather than a WIT text tree: therefore we must do a wit build rather than a wit fetch.Is that correct? That
go tool wit-bindgen-gocan't operate on the text tree, only on a binary package reference? I'm a bit surprised by that but the one thing I do know about Go is its infinite capacity to surprise me! grinIf that is the reason, I'd suggest explicitly explaining this context, because reading this now the build step feels a bit arbitrary, likely as a result of partial updates as the Go tooling has changed over time...