Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Go is a statically typed, compiled language that Google engineers Robert Griesemer, Rob Pike, and Ken Thompson introduced in 2009 to make large-scale server software simpler to build and maintain. Its deliberately small feature set, fast compilation, built-in concurrency through goroutines and channels, and a garbage collector place it in a pragmatic middle ground between C and higher-level languages. It is the language behind Docker, Kubernetes, Terraform, and Prometheus, and it is widely used for cloud infrastructure, microservices, and command-line tools. On XCODX your code runs through go run on a package named main inside a cloud sandbox, with the full standard library available but no module downloads. The Go version in use is shown in the badge above the editor.
package main
import (
"fmt"
"strings"
)
func main() {
names := []string{"Ada", "Linus", "Grace"}
for _, name := range names {
fmt.Printf("Hello, %s!\n", name)
}
nums := []int{4, 8, 15, 16, 23, 42}
sum := 0
for _, n := range nums {
sum += n
}
fmt.Println("Sum:", sum)
fmt.Println(strings.ToUpper("done"))
}
Go's strengths are fast compilation, a small and consistent syntax teams can learn quickly, first-class concurrency, and a standard library rich enough to build a production HTTP server with no dependencies. Choose it for network services, microservices, DevOps and CLI tooling, and anywhere predictable performance and easy deployment as a single static binary matter more than squeezing out maximum speed. It is a weaker fit for CPU-bound systems programming that needs manual memory control or the strongest compile-time safety guarantees, where Rust or C tend to win. In this sandbox Go is well suited to practicing algorithms, concurrency patterns, and standard-library APIs, though its networking and file features have nothing external to reach.
No. XCODX runs your code with go run in a cloud sandbox that has no network and no module cache, so go get, go mod download, and any import of a third-party package will fail. Everything under the standard library - fmt, bufio, os, strings, strconv, sort, sync, encoding/json and the rest - is available. If a program imports something outside the standard library, it will not build here.
For simple space-separated values, fmt.Scan and fmt.Scanln read straight into variables; for whole lines, bufio.NewScanner(os.Stdin) with scanner.Scan() and scanner.Text() is the idiomatic choice. XCODX gives you a live interactive terminal that streams your keystrokes, or a Stdin Box to paste input up front. Reads block while waiting for input, and the stream ends when you press Ctrl+D, at which point Scan() returns false.
Go treats an unused local variable or an unused import as a compile error, not a warning, so the program will not run until you fix it. This surprises beginners coming from other languages, but it keeps code tidy. Remove the unused import, or assign a value you deliberately want to ignore to the blank identifier _.
Yes, as long as every file declares package main; the sandbox compiles the files together as one package, so functions and types defined in one file are visible in the others without importing between them. They simply share the same package namespace. What you cannot do is pull in external packages, since there is no network for go get.
Yes. Goroutines, channels, select, and the sync package all run normally within a single process. Remember that the program exits as soon as main returns, so a goroutine that has not finished gets cut off - use sync.WaitGroup or channel signaling to wait for background work. Because each run has a short time limit, keep concurrent examples quick and avoid deadlocks, which will hang until the run is killed.
Your code is compiled and executed with go run on each run, and the exact Go version appears in the version badge above the editor. There is no go build artifact to keep, because the sandbox filesystem is fresh every run and nothing persists between executions. That is ideal for learning and testing snippets; for a real project you would install Go locally.
main.gogofmt.Scan() / bufio.NewScanner(os.Stdin)package main
import "fmt"
func main() {
fmt.Println("Hello from Go!")
fmt.Println("Welcome to XCODX Online Compiler!")
}