Go
Go 1.22

Run Go 1.22 Online

Compile and execute Go code instantly in a secure, isolated sandbox. No setup, no installs — just write and run.

main.go
Output
Click "Run Code" to execute...

About Go

Go is a fast, compiled language created by Google, designed for systems programming, cloud infrastructure, and microservices. With built-in concurrency via goroutines and channels, it excels at building scalable, high-performance applications.

Our sandbox runs Go 1.22 with full standard library support.

Sandbox Features

  • Secure execution with Docker + gVisor isolation
  • Go 1.22 with full standard library
  • Up to 300s execution time (Pro tier)
  • Stdin support for interactive programs
  • REST API for programmatic access
  • No setup or installation required

Use Go with stateful sessions

Open a session once, then call execute repeatedly — variables, files, and installed packages persist between runs. Perfect for code interpreters and REPL-style agents.

# 1. Create a session
curl -X POST https://api.sandboxapi.dev/v1/sessions \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"language":"go","idle_ttl":300}'
# → {"id":"sess_abc","language":"go",...}

# 2. Execute — first call
curl -X POST https://api.sandboxapi.dev/v1/sessions/sess_abc/execute \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"code":"x := 42; _ = x"}'

# 3. Execute again — state carries over
curl -X POST https://api.sandboxapi.dev/v1/sessions/sess_abc/execute \
  -H "X-RapidAPI-Key: $KEY" \
  -d '{"code":"// Note: Go is compiled — sessions persist files, not REPL state"}'

Note: Go is a compiled language. Sessions persist installed packages and files on disk, but variable state does not carry between calls. Use multi-file submissions or write intermediate state to disk.

Read the sessions docs →

Run Code in Other Languages

Need More? Get API Access

Integrate secure code execution into your own apps with our REST API. Free tier includes 500 executions per month.

Get API Key on RapidAPI