Online Go Editor and Playground
Free online Go editor with real-time execution, standard library support, and concurrency features. Perfect for learning Go, testing code, and practicing concurrent programming.
Loading editor...
Features
Go Execution
Execute Go code directly in your browser
Standard Library
Access to Go's standard library packages
Concurrency
Test goroutines and channels in action
Error Handling
Clear compilation and runtime error messages
Package Support
Multi-package support and imports
Code Sharing
Share Go code snippets with others
Frequently Asked Questions
How to get started with Go?
Let's start with the basics:
package main
import "fmt"
func main() {
// Print a message
fmt.Println("Hello, World!")
// Define variables
var name string = "Go"
age := 14 // Type inference
// Basic types
var (
integer int = 42
boolean bool = true
text string = "Go is fun"
)
}
Our editor provides real-time compilation and execution feedback.
How to work with Go slices and maps?
Examples of working with slices and maps:
// Slices
numbers := []int{1, 2, 3}
numbers = append(numbers, 4)
// Create slice with make
slice := make([]int, 0, 10)
// Maps
person := map[string]string{
"name": "John",
"role": "Developer",
}
// Access and modify map
fmt.Println(person["name"])
person["role"] = "Senior Developer"
Practice these data structures in our editor.
How to use Go concurrency features?
Learn Go's powerful concurrency features:
package main
import (
"fmt"
"sync"
)
func main() {
// Channels
ch := make(chan int)
go func() {
ch <- 42 // Send
}()
value := <-ch // Receive
// WaitGroup
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
fmt.Println("Goroutine running")
}()
wg.Wait()
}
Test concurrent code safely in our environment.
How to handle errors in Go?
Explore error handling patterns:
package main
import (
"errors"
"fmt"
)
// Function returning error
func divide(a, b float64) (float64, error) {
if b == 0 {
return 0, errors.New("division by zero")
}
return a/b, nil
}
// Custom error type
type ValidationError struct {
Field string
Message string
}
func (e *ValidationError) Error() string {
return fmt.Sprintf("%s: %s", e.Field, e.Message)
}
Practice error handling patterns with immediate feedback.
How to create and use interfaces in Go?
Understanding Go interfaces:
package main
import "math"
// Define interface
type Shape interface {
Area() float64
}
// Implement interface
type Circle struct {
Radius float64
}
func (c Circle) Area() float64 {
return math.Pi * c.Radius * c.Radius
}
func main() {
var s Shape = Circle{Radius: 5}
fmt.Printf("Area: %.2f\n", s.Area())
}
Test interface implementations in our editor.
How to write tests in Go?
Learn Go testing patterns:
// math_test.go
package math
import "testing"
func TestAdd(t *testing.T) {
tests := []struct {
name string
a, b int
want int
}{
{"positive", 2, 3, 5},
{"negative", -2, -3, -5},
{"zero", 0, 0, 0},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := Add(tt.a, tt.b)
if got != tt.want {
t.Errorf("Add() = %v, want %v", got, tt.want)
}
})
}
}
Practice testing with our built-in test runner.