Go quick reference

Runs in Zerethon IDE · Go 1.27 Official Go documentation ↗

Go 1.27 essentials: variables and types, control flow, functions and errors, slices and maps, structs and interfaces, goroutines, input and files — and how a Go program is built and run in Zerethon IDE.

Written for Go 1.27. Examples that show an output were run in the Zerethon sandbox (Go 1.27) on 2026-10-24.

Basics

  • Hello, World

    The smallest Go program: package main, func main() and fmt.Println.

  • Variables and types

    var and :=, the basic types, constants, zero values and converting between types with strconv.

  • Conditions and loops

    if / else, switch, and for — Go's only loop — with a counter, a condition or range.

  • Functions and errors

    Define functions with func, return several values, and return an error instead of throwing.

Data

  • Slices, arrays and maps

    Grow a slice with append, look up a map with the comma-ok form, and sort with slices and sort.

  • Structs, methods and interfaces

    Group fields in a struct, attach methods, and accept any type that has the right methods with an interface.

  • Strings

    The strings package, formatting with fmt.Sprintf, bytes vs runes, and regular expressions with regexp.

  • Goroutines and channels

    Run functions concurrently with go, wait with sync.WaitGroup, and pass results over a channel.

Input and files

  • Reading input (stdin)

    Read what you type in the IDE's Input tab with fmt.Fscan or line by line with bufio.Scanner.

  • Reading and writing files

    Read project files with os.ReadFile or os.Open, parse CSV and JSON, and write temporary files under /tmp.

  • Several files and packages

    Split package main over several files in one folder; what the standard library offers without installing anything.

In Zerethon IDE

  • Running Go in Zerethon IDE

    What Run builds, the time limit, input, tests, and what a run cannot do.

  • Common errors

    Compile errors such as declared and not used and undefined, and runtime panics such as index out of range and nil map.

  • Official documentation

    Where to read more: A Tour of Go, Effective Go, the standard library and the language specification.

References