Choose TypeScript, Go, Rust or C++ and find syntax, everyday APIs, standard libraries and tools in one place.
Scope and conventions
TypeScript/Node, Go 1.23+, Rust 2024 and C++23: from a first CLI to files, JSON, HTTP, concurrency and testing. Complete programs are labeled; other examples identify their surrounding code/imports. Optional libraries and version requirements are named in each entry.
int is platform-sized; float64 is floating point. byte aliases uint8; rune aliases int32. []T is a slice; [N]T is a fixed-size array. make allocates a slice of the given length.
Fragment
Type declaration at file scope; value statements inside a function.
main.go
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
type Point struct { X, Y int}p := Point{X: 2, Y: 5}buffer := make([]byte, 3)
& takes an address; *T names a pointer type. a[:n] is a slice excluding n. _ ignores a value. Double quotes make strings; single quotes make rune literals; most semicolons are inserted.
nil applies to pointers, slices, maps, functions, channels and interfaces, not int/string/bool. Optional scalar values commonly use a pointer or a separate bool. An interface containing a typed nil pointer is not itself nil.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.go
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
var score *int // nil means no scorevalue := 0score = &value // present zeropresent := score != nil
struct groups typed fields; type gives the structure a name. Use a keyed literal to name field initializers. Capitalized fields are exported outside their package.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.go
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
type Point struct { X int Y int}point := Point{X: 2, Y: 5}point.Y = 8
Go has multiple return values and assignment, but no general built-in tuple type. Each name receives one result; _ discards a result. Do not use _ to silently discard an error you must handle.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
Named integer types plus const/iota commonly name modes. They do not restrict a value to only the listed constants. Go has no built-in algebraic data type with Rust-style payload variants.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
Type parameters use square brackets. any allows any type; constraints such as comparable or an interface restrict operations/types. Generic functions were introduced in Go 1.18.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
A type satisfies an interface implicitly through its method set. Value and pointer receivers affect which method sets satisfy it. There is no implements declaration.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.go
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
type Named interface { Name() string}type Place struct{}func (Place) Name() string { return "north"}var item Named = Place{}
A type assertion checks an interface’s dynamic type. The two-result form reports failure without panicking. A type conversion such as int64(n) is separate and does not automatically check numeric range.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.go
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
var value any = "north"text, ok := value.(string)if ok { _ = text}