-
-
Notifications
You must be signed in to change notification settings - Fork 236
Feature support go wasm #866
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
hatemhosny
merged 28 commits into
live-codes:develop
from
Muhammad-Ayman:Feature_Support_Go_wasm
Sep 22, 2025
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
3531576
init
Muhammad-Ayman 0178064
lint:prettier
Muhammad-Ayman d4da641
restore templates.js
Muhammad-Ayman 4cc3352
fix rating issues
Muhammad-Ayman 419a690
fix test
Muhammad-Ayman b2bba60
give up on e2e XD
Muhammad-Ayman 419cd4d
fix the “runs once only” behavior
Muhammad-Ayman eecb75f
fix Quality Gate
Muhammad-Ayman f865ca5
test:lint
Muhammad-Ayman 0719401
edit go-wasm script
hatemhosny f05fe7f
fixes
hatemhosny d9443b7
Merge pull request #1 from live-codes/go-wasm
Muhammad-Ayman cd349bd
Merge branch 'develop' into Feature_Support_Go_wasm
hatemhosny 3a78ade
Stdin Buffer Management
Muhammad-Ayman 9208fb8
JavaScript gets current count from Ui
Muhammad-Ayman 8e77243
fix Loading... issue
Muhammad-Ayman 169f23c
finish the starter
Muhammad-Ayman b5e57a8
add info
Muhammad-Ayman af05c0b
Merge branch 'develop' into Feature_Support_Go_wasm
hatemhosny 2fb2d3d
minor edits
hatemhosny f156468
add docs for go & go-wasm
hatemhosny b59fff5
add licenses
hatemhosny e49863f
Yaegi WebAssembly - Guide
Muhammad-Ayman 2536438
Merge branch 'develop' into Feature_Support_Go_wasm
hatemhosny 9482640
Revert "Yaegi WebAssembly - Guide"
Muhammad-Ayman 7b87bee
add link to `yaegi-wasm` repo and license
hatemhosny cadba67
run `i18n-export`
hatemhosny 69c83da
Merge branch 'develop' into Feature_Support_Go_wasm
hatemhosny 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
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,93 @@ | ||
| # Go (Wasm) | ||
|
|
||
| [Go](https://go.dev/) (Golang), is an open-source, statically typed, and compiled programming language developed by Google. It is designed for simplicity, efficiency, and strong support for concurrency, making it well-suited for building scalable and high-performance applications. | ||
|
|
||
| LiveCodes uses [Yaegi](https://github.com/traefik/yaegi), the Go interpreter (running on WebAssembly), to run Go in the browser. | ||
|
|
||
| :::info Note | ||
|
|
||
| LiveCodes also supports running Go using [GopherJS](https://github.com/gopherjs/gopherjs) which is a Go to JavaScript compiler. Read documentation [here](./go.mdx). | ||
|
|
||
| ::: | ||
|
|
||
| ## Demo | ||
|
|
||
| import LiveCodes from '../../src/components/LiveCodes.tsx'; | ||
|
|
||
| export const params = { | ||
| 'go-wasm': 'package main\n\nimport "fmt"\n\nfunc main() {\n\tfmt.Println("Hello, World!")\n}\n', | ||
| console: 'full', | ||
| }; | ||
|
|
||
| <LiveCodes params={params}></LiveCodes> | ||
|
|
||
| ## Usage | ||
|
|
||
| LiveCodes runs Go in the browser, including the [standard library](https://pkg.go.dev/std). | ||
|
|
||
|
|
||
| ### Communication with JavaScript | ||
|
|
||
| The Go code runs in the context of the [result page](../features/result.mdx). | ||
| A few helper properties and methods are available in the browser global `livecodes.goWasm` object: | ||
|
|
||
| - `livecodes.goWasm.input`: the initial standard input that is passed to the Go code. | ||
| - `livecodes.goWasm.loaded`: A promise that resolves when the Go environment is loaded. Any other helpers should be used after this promise resolves. | ||
| - `livecodes.goWasm.output`: the standard output. | ||
| - `livecodes.goWasm.error`: the standard error. | ||
| - `livecodes.goWasm.exitCode`: the exit code. | ||
| - `livecodes.goWasm.run`: a function that runs the Go code with new input. This function takes a string as input and returns a promise that resolves when the Go code is done running. The promise resolves with an object containing the `input`, `output`, `error`, and `exitCode` properties. | ||
|
|
||
| See the [example below](#example-usage) for more details. | ||
|
|
||
| ## Language Info | ||
|
|
||
| ### Name | ||
|
|
||
| `go-wasm` | ||
|
|
||
| ### Extensions | ||
|
|
||
| `wasm.go`, `go-wasm`, `gowasm` | ||
|
|
||
| ### Editor | ||
|
|
||
| `script` | ||
|
|
||
| ## Compiler | ||
|
|
||
| [Yaegi](https://github.com/traefik/yaegi), compiled to WebAssembly ([yaegi-wasm](https://github.com/Muhammad-Ayman/yaegi-wasm)) | ||
|
|
||
| ### Version | ||
|
|
||
| Yaegi v0.16.1, running go1.25.0 | ||
|
|
||
| ## Code Formatting | ||
|
|
||
| Using [GopherJS](https://github.com/gopherjs/gopherjs) | ||
|
|
||
| ## Example Usage | ||
|
|
||
| This example demonstrates standard library usage and JavaScript interoperability (also check the code in the HTML editor): | ||
|
|
||
| <LiveCodes template="go-wasm" height="80vh"></LiveCodes> | ||
|
|
||
|
|
||
| ## Live Reload | ||
|
|
||
| By default, new code changes are sent to the result page for re-evaluation without a full page reload, to avoid the need to reload the Go environment. | ||
|
|
||
| This behavior can be disabled by adding the code comment `// __livecodes_reload__` to the code, which will force a full page reload. | ||
| This comment can be added in the [`hiddenContent` property of the editor](../configuration/configuration-object.mdx#markup) for embedded playgrounds. | ||
|
|
||
| ## Starter Template | ||
|
|
||
| https://livecodes.io/?template=go-wasm | ||
|
|
||
| ## Links | ||
|
|
||
| - [Go](https://go.dev/) | ||
| - [Go documentation](https://go.dev/doc/) | ||
| - [Go standard library](https://pkg.go.dev/std) | ||
| - [Yaegi](https://github.com/traefik/yaegi) | ||
| - [Go using GopherJS](./go.mdx) in LiveCodes | ||
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 |
|---|---|---|
| @@ -1,3 +1,72 @@ | ||
| # Go (Golang) | ||
|
|
||
| TODO... | ||
| [Go](https://go.dev/) (Golang), is an open-source, statically typed, and compiled programming language developed by Google. It is designed for simplicity, efficiency, and strong support for concurrency, making it well-suited for building scalable and high-performance applications. | ||
|
|
||
| LiveCodes uses [GopherJS](https://github.com/gopherjs/gopherjs) which is a Go to JavaScript compiler, to run Go in the browser. | ||
|
|
||
| :::info Note | ||
|
|
||
| LiveCodes also supports running Go using [Yaegi](https://github.com/traefik/yaegi), the Go interpreter (running on WebAssembly). Read documentation [here](./go-wasm.mdx). | ||
|
|
||
| ::: | ||
|
|
||
| ## Demo | ||
|
|
||
| import LiveCodes from '../../src/components/LiveCodes.tsx'; | ||
|
|
||
| export const params = { | ||
| 'go': 'package main\n\nimport "fmt"\n\nfunc main() {\n\tfmt.Println("Hello, World!")\n}\n', | ||
| console: 'full', | ||
| }; | ||
|
|
||
| <LiveCodes params={params}></LiveCodes> | ||
|
|
||
| ## Usage | ||
|
|
||
| LiveCodes runs Go in the browser, including the [standard library](https://pkg.go.dev/std). | ||
|
|
||
| JavaScript interoperability and DOM access is achieved using [package `js`](https://pkg.go.dev/syscall/js) (see the [example below](#example-usage)). | ||
|
|
||
| ## Language Info | ||
|
|
||
| ### Name | ||
|
|
||
| `go` | ||
|
|
||
| ### Extensions | ||
|
|
||
| `go`, `golang` | ||
|
|
||
| ### Editor | ||
|
|
||
| `script` | ||
|
|
||
| ## Compiler | ||
|
|
||
| [GopherJS](https://github.com/gopherjs/gopherjs), the Go to JavaScript compiler. | ||
|
|
||
| ### Version | ||
|
|
||
| GopherJS v1.19.0 beta1, running Go 1.19.13 | ||
|
|
||
| ## Code Formatting | ||
|
|
||
| Using [GopherJS](https://github.com/gopherjs/gopherjs) | ||
|
|
||
| ## Example Usage | ||
|
|
||
| This example demonstrates standard library usage, JavaScript interoperability and DOM access: | ||
|
|
||
| <LiveCodes template="go" height="80vh"></LiveCodes> | ||
|
|
||
| ## Starter Template | ||
|
|
||
| https://livecodes.io/?template=go | ||
|
|
||
| ## Links | ||
|
|
||
| - [Go](https://go.dev/) | ||
| - [Go documentation](https://go.dev/doc/) | ||
| - [Go standard library](https://pkg.go.dev/std) | ||
| - [GopherJS](https://github.com/gopherjs/gopherjs) | ||
| - [Go using Yaegi](./go-wasm.mdx) in LiveCodes |
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
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
Oops, something went wrong.
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.
💡 Verification agent
🧩 Analysis chain
Align the documented JS API with the actual implementation.
The worker implementation exposes additional fields (e.g., worker, ready). Ensure names and shapes match exactly or the docs will drift.
Run to verify exported properties and update this list accordingly:
If confirmed, amend the bullets, for example:
🏁 Script executed:
Length of output: 6148
Update docs to match livecodes.goWasm runtime API (add worker + ready)
Add bullets for
livecodes.goWasm.worker(Worker reference — worker gets a.loadedflag) andlivecodes.goWasm.ready(boolean that becomes true after a run); clarifylivecodes.goWasm.loadedremains a Promise that resolves oncereadyis true. Edit docs/docs/languages/go-wasm.mdx (lines ~34–41). Implementation reference: src/livecodes/languages/go-wasm/lang-go-wasm-script.ts (~109–174).🤖 Prompt for AI Agents