Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3531576
init
Muhammad-Ayman Sep 1, 2025
0178064
lint:prettier
Muhammad-Ayman Sep 1, 2025
d4da641
restore templates.js
Muhammad-Ayman Sep 1, 2025
4cc3352
fix rating issues
Muhammad-Ayman Sep 2, 2025
419a690
fix test
Muhammad-Ayman Sep 2, 2025
b2bba60
give up on e2e XD
Muhammad-Ayman Sep 2, 2025
419cd4d
fix the “runs once only” behavior
Muhammad-Ayman Sep 3, 2025
eecb75f
fix Quality Gate
Muhammad-Ayman Sep 3, 2025
f865ca5
test:lint
Muhammad-Ayman Sep 3, 2025
0719401
edit go-wasm script
hatemhosny Sep 3, 2025
f05fe7f
fixes
hatemhosny Sep 3, 2025
d9443b7
Merge pull request #1 from live-codes/go-wasm
Muhammad-Ayman Sep 8, 2025
cd349bd
Merge branch 'develop' into Feature_Support_Go_wasm
hatemhosny Sep 8, 2025
3a78ade
Stdin Buffer Management
Muhammad-Ayman Sep 10, 2025
9208fb8
JavaScript gets current count from Ui
Muhammad-Ayman Sep 10, 2025
8e77243
fix Loading... issue
Muhammad-Ayman Sep 10, 2025
169f23c
finish the starter
Muhammad-Ayman Sep 10, 2025
b5e57a8
add info
Muhammad-Ayman Sep 11, 2025
af05c0b
Merge branch 'develop' into Feature_Support_Go_wasm
hatemhosny Sep 13, 2025
2fb2d3d
minor edits
hatemhosny Sep 14, 2025
f156468
add docs for go & go-wasm
hatemhosny Sep 14, 2025
b59fff5
add licenses
hatemhosny Sep 14, 2025
e49863f
Yaegi WebAssembly - Guide
Muhammad-Ayman Sep 15, 2025
2536438
Merge branch 'develop' into Feature_Support_Go_wasm
hatemhosny Sep 15, 2025
9482640
Revert "Yaegi WebAssembly - Guide"
Muhammad-Ayman Sep 17, 2025
7b87bee
add link to `yaegi-wasm` repo and license
hatemhosny Sep 18, 2025
cadba67
run `i18n-export`
hatemhosny Sep 18, 2025
69c83da
Merge branch 'develop' into Feature_Support_Go_wasm
hatemhosny Sep 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A [feature-rich](https://livecodes.io/docs/features/), open-source, **client-sid
[![LiveCodes: npm version](https://img.shields.io/npm/v/livecodes)](https://www.npmjs.com/package/livecodes)
[![LiveCodes: npm downloads](https://img.shields.io/npm/dm/livecodes)](https://www.npmjs.com/package/livecodes)
[![LiveCodes: jsdelivr downloads](https://data.jsdelivr.com/v1/package/npm/livecodes/badge?style=rounded)](https://www.jsdelivr.com/package/npm/livecodes)
[![LiveCodes: languages](https://img.shields.io/badge/languages-96-blue)](https://livecodes.io/docs/languages/)
[![LiveCodes: languages](https://img.shields.io/badge/languages-97-blue)](https://livecodes.io/docs/languages/)
[![LiveCodes: docs](https://img.shields.io/badge/Documentation-575757?logo=gitbook&logoColor=white)](https://livecodes.io/docs/)
[![LiveCodes: llms.txt](https://img.shields.io/badge/llms.txt-575757?logo=googledocs&logoColor=white)](https://livecodes.io/docs/llms.txt)
[![LiveCodes: llms-full.txt](https://img.shields.io/badge/llms--full.txt-575757?logo=googledocs&logoColor=white)](https://livecodes.io/docs/llms-full.txt)
Expand Down
93 changes: 93 additions & 0 deletions docs/docs/languages/go-wasm.mdx
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.
Comment on lines +34 to +41
Copy link

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:

 - `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.ready`: boolean flag that becomes true after load.
+- `livecodes.goWasm.worker`: reference to the underlying Web Worker.

🏁 Script executed:

#!/bin/bash
# Verify goWasm API surface
rg -nC2 --type=ts '\blivecodes\.goWasm\b' src | cat
rg -nC2 --type=ts 'export const goWasm|goWasm\s*=' src/livecodes/languages/go-wasm -g '!**/dist/**' | cat

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 .loaded flag) and livecodes.goWasm.ready (boolean that becomes true after a run); clarify livecodes.goWasm.loaded remains a Promise that resolves once ready is 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
In docs/docs/languages/go-wasm.mdx around lines 34 to 41, the documentation is
missing two runtime API properties and needs clarification: add a bullet for
livecodes.goWasm.worker describing it as the Worker reference (note: the worker
object has a .loaded flag), add a bullet for livecodes.goWasm.ready describing
it as a boolean that becomes true after a run completes, and update the
livecodes.goWasm.loaded bullet to state it remains a Promise that resolves once
ready is true; ensure the run bullet still describes the function signature and
returned object and keep wording consistent with the implementation in
src/livecodes/languages/go-wasm/lang-go-wasm-script.ts (~109–174).


## 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
71 changes: 70 additions & 1 deletion docs/docs/languages/go.mdx
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
1 change: 1 addition & 0 deletions docs/src/components/LanguageSliders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export default function Sliders() {
{ name: 'ruby', title: 'Ruby' },
{ name: 'ruby-wasm', title: 'Ruby (Wasm)' },
{ name: 'go', title: 'Go' },
{ name: 'go-wasm', title: 'Go (Wasm)' },
{ name: 'php', title: 'PHP' },
{ name: 'php-wasm', title: 'PHP (Wasm)' },
{ name: 'cpp', title: 'C++' },
Expand Down
1 change: 1 addition & 0 deletions docs/src/components/TemplateList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const templates = [
{ name: 'ruby', title: 'Ruby Starter', thumbnail: 'ruby.svg' },
{ name: 'ruby-wasm', title: 'Ruby (Wasm) Starter', thumbnail: 'ruby.svg' },
{ name: 'go', title: 'Go Starter', thumbnail: 'go.svg' },
{ name: 'go-wasm', title: 'Go (Wasm) Starter', thumbnail: 'go.svg' },
{ name: 'php', title: 'PHP Starter', thumbnail: 'php.svg' },
{ name: 'php-wasm', title: 'PHP (Wasm) Starter', thumbnail: 'php.svg' },
{ name: 'cpp', title: 'C++ Starter', thumbnail: 'cpp.svg' },
Expand Down
Loading