Go Compiler
Compile and run Go code online with the official Go 1.27 compiler, goroutines and stdin input. It compiles to WebAssembly in your browser, so code stays private.
Something not working, or missing a feature? Send feedback
About the Go Compiler
The online Go Compiler builds your program with the official Go 1.27 compiler and linker and runs it immediately, so you can try generics, goroutines and channels or check an interview answer without installing Go. The toolchain itself runs in your browser as WebAssembly, so your code is never uploaded.
Your code runs in an isolated Web Worker in your browser, so it never leaves your device.
How to use the Go Compiler
- Write or paste a Go program with package main and a main() function.
- Put any input your program reads from os.Stdin (bufio.Scanner, fmt.Scan) in the stdin box.
- Click Run. The first run downloads the Go toolchain (about 23 MB); later runs reuse it.
- Fix compiler errors (they show the line and column), then read the output and exit code.
Example
Input
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
sum := 0
for scanner.Scan() {
for _, field := range strings.Fields(scanner.Text()) {
n, err := strconv.Atoi(field)
if err != nil {
fmt.Fprintln(os.Stderr, "not a number:", field)
continue
}
sum += n
}
}
fmt.Println("Sum:", sum)
}Result
Sum: 108
With "4 8 15" and "16 23 42" on two stdin lines. scanner.Scan returns false when the stdin box is used up, which ends the loop.
Common mistakes
- Unused imports and variables. Go refuses to compile a program with an unused import or local variable ("imported and not used", "declared and not used"). Remove it, or assign the variable to _ while you experiment.
- Packages that need a network or an operating system. net/http, os/exec and database drivers are not available, and there is no network. Common packages such as fmt, strings, strconv, sort, slices, maps, math, time, sync, regexp and encoding/json are; the compiler names any package it cannot find.
- Waiting forever. A program whose goroutines all block (an unbuffered channel nobody reads, an empty select{}) stops with Go’s "all goroutines are asleep - deadlock!" error. A loop that never ends is stopped at the time limit.
Works well with the Go Compiler
- JSON to Go: generate struct types for the JSON your program decodes.
- C Compiler: compare the same algorithm in C.
- Text & Code Diff: compare the output with the expected answer.
Frequently asked questions
Which Go version is used?
Go 1.27, the official gc compiler and linker built for WebAssembly. Generics, range over integers and functions, min and max, and the slices and maps packages all work.
Is it the real Go compiler or an interpreter?
The real compiler. Your code is compiled and linked to a WebAssembly binary exactly as go build would do, so compile errors, panics and the deadlock detector behave like they do on your computer.
Do goroutines and channels work?
Yes. Goroutines, channels, select, the sync package and time.Sleep all work. WebAssembly is single-threaded, so goroutines take turns on one thread instead of running in parallel.
Is my code sent to a server?
No. The Go compiler, the linker and your program all run in your browser as WebAssembly, so the code and its input stay on your device.
Can my program read and write files?
Yes, in a temporary in-memory file system: os.WriteFile and os.ReadFile work under /tmp during a run, and everything is gone when the run ends.
Related tools
JavaScript Compiler
Run JavaScript online in an isolated browser sandbox. See console output, errors and execution time instantly, with top-level await and stdin input.
TypeScript Compiler
Compile and run TypeScript online. Your code is type-checked with the official compiler in strict mode, then runs in a sandboxed worker in your browser.
Python Compiler
Run Python 3 code online with the full standard library and stdin input. It runs in your browser with Pyodide (WebAssembly), so your code stays on your device.
PHP Compiler
Run PHP 8.4 code online and see the output instantly, with stdin input and mbstring. PHP runs in your browser with WebAssembly, so your code stays private.
C Compiler
Compile and run C code online with Clang 21, a GCC-compatible compiler, and stdin input. Programs run in your browser as WebAssembly, so your code stays private.
C++ Compiler
Compile and run C++20 code online with Clang 21, libc++ and stdin input. Programs compile to WebAssembly and run in your browser, so your code stays private.