Online Go Compiler
Write, run and test Go code online, right in your browser. This free online Go compiler needs no installation or signup — just type your code and click Run.
Go (Golang) is a simple, fast, compiled language from Google with built-in concurrency, popular for cloud services, CLIs and backend APIs.
How to use the Go compiler
- Write or paste your Go code in the editor.
- If your program reads input, open the I/O tab and type it into the STDIN box (one value per line).
- Click Run — the output and any errors appear in the output panel.
Sample: read input in Go
package main
import "fmt"
func main() {
var name string
fmt.Scanln(&name)
fmt.Printf("Hello, %s!\n", name)
}
Paste this into the editor, type your name in the STDIN box and click Run.
More Go examples to try
Slices and maps
Counts word frequency with a map — a typical Go exercise.
package main
import (
"fmt"
"strings"
)
func main() {
text := "go is fun and go is fast"
counts := map[string]int{}
for _, w := range strings.Fields(text) {
counts[w]++
}
fmt.Println(counts)
}
Goroutines and channels
Runs work concurrently and collects results through a channel.
package main
import "fmt"
func square(n int, ch chan<- int) {
ch <- n * n
}
func main() {
ch := make(chan int)
for i := 1; i <= 5; i++ {
go square(i, ch)
}
sum := 0
for i := 0; i < 5; i++ {
sum += <-ch
}
fmt.Println("Sum of squares:", sum)
}
Common Go errors and how to fix them
declared and not used- Go refuses to compile unused variables. Use the variable, remove it, or assign it to
_. imported and not used- Remove the unused import from the
importblock. fatal error: all goroutines are asleep - deadlock!- A channel send or receive is waiting forever. Make sure every receive has a matching send, or use a buffered channel.
panic: runtime error: index out of range- You accessed a slice beyond its length. Check
len(s)before indexing.
Frequently asked questions
Is this online Go compiler free?
Yes. It is completely free to use, with no signup required to write and run code.
Do I need to install anything?
No. It all works from your web browser, so there is nothing to download or set up — it works on Windows, macOS, Linux, Chromebooks and phones.
How do I give input to my Go program?
Before clicking Run, type the input into the STDIN box under the I/O tab, one value per line. Your program reads it as standard input, just like typing in a terminal.
Is this good for learning Go?
Yes. It is ideal for practising exercises, testing small programs and trying out ideas from tutorials, because you can run code instantly without configuring an environment.
Other online compilers
Python Compiler Java Compiler C Compiler C++ Compiler C# Compiler JavaScript Compiler TypeScript Compiler SQL Compiler React.js Compiler HTML Compiler Rust Compiler R Compiler PHP Compiler Kotlin Compiler Swift Compiler Scala Compiler Dart Compiler Ruby Compiler Prolog Compiler Perl Compiler
Editor powered by OneCompiler.