b2KIT

Go Playground (WASM)

Write and run Go code in the browser compiled to WebAssembly with standard output display.

Tested tool guide Tested browser tools Checked August 16, 2026

What Go Playground (WASM) does, with a checked example

Go Playground (WASM) accepts a complete Go program, compiles it to WebAssembly in the browser, runs it, and displays text written to standard output. It is useful for checking small language experiments, formatting behavior, and deterministic calculations without invoking a local Go toolchain. The important boundary is the compilation target: a successful browser run demonstrates behavior under Go and WebAssembly in this page, not necessarily under a native executable. Code that assumes direct access to operating-system facilities can therefore be a poor fit even when its Go syntax is valid.

Worked example

A concrete input and expected output from the current implementation.

Input

package main

import "fmt"

func main() {
    a, b := 7, 5
    fmt.Printf("%d + %d = %d\n", a, b, a+b)
    fmt.Println("squares:", a*a, b*b)
}

Expected output

7 + 5 = 12
squares: 49 25

Adding 7 and 5 produces 12. Multiplying each integer by itself produces 49 and 25; Printf formats the first line, while Println separates its arguments with spaces and terminates the second line.

How the result is produced

1

Runnable Go source

The editor expects runnable Go source, so a minimal executable declares package main and defines func main(). Selecting Run compiles that program for WebAssembly and starts it inside the browser. Imports, declarations, and expressions must form a valid Go program. This is not an expression evaluator that automatically wraps a fragment such as 2 + 2.

2

Standard output

The result area records what the running program writes to standard output. Calls such as fmt.Print, fmt.Println, and fmt.Printf therefore produce visible text, including their spacing and newline choices. Merely calculating or assigning a value produces no output line. Compilation and execution occur in the page, so the source is not uploaded for remote execution.

Good uses

  • Check the exact spacing, substitution, and newline behavior of a short fmt.Printf or fmt.Println call.
  • Try a self-contained example involving slices, maps, loops, interfaces, or error handling before moving it into a larger Go program.
  • Run a small deterministic calculation on a machine where installing or invoking a local Go toolchain is inconvenient.

Limits and checks

  • Input must be a runnable program, not a bare expression. Include package main, any required imports, and func main().
  • Browser-targeted WebAssembly is not the same environment as a native Go binary. Programs involving local files, child processes, raw sockets, terminal behavior, or OS-specific packages may fail or behave differently.
  • Do not treat elapsed time in this playground as a native performance benchmark. Browser scheduling, WebAssembly execution, startup work, and the surrounding page can all affect timing.

Common questions

Can this playground run any Go program?

No. It is suited to self-contained code that can compile for the browser's WebAssembly target. Programs requiring an unavailable operating-system service, external command, device, or target-specific native behavior are outside its reliable scope. A compilation or runtime failure can reflect the target environment as well as a mistake in the source.

Does matching output prove that the program will behave identically as a native binary?

No. It can verify the displayed standard output and language-level result for this browser run. It does not establish identical filesystem access, networking, concurrency timing, memory use, or performance on linux/amd64 or another native target. Build and test in the intended deployment environment before relying on target-specific behavior.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools