Reference

Programming languages

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.

Files & dependencies

Read imports and qualified names

Go

Files belong to a package. import makes another package available through a qualified name. Uppercase names are exported. go.mod identifies the module containing packages.

Fragment

Complete main.go in an initialized module.

main.go
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
package main

import (
  "fmt"
  "os"
)

func main() {
  fmt.Fprintln(os.Stdout, "north")
}

Read public and private boundaries

Go

Capitalized package-level identifiers and field/method names are exported. Lowercase names are package-private, not private to one file. Files in the same package share the package namespace.

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+
package places

const DefaultName = "north"
const internalName = "west"

type Place struct {
  Name string
  note string
}

Split code across local files

Go

Ordinary files in one directory normally share a package and can use each other’s package-level names directly. Import paths identify packages, not individual .go files. This main package uses both files together.

Fragment

Two complete files in one initialized module directory; run with go run .

main.go
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
// names.go
package main

const name = "north"

// main.go
package main

import "fmt"

func main() {
  fmt.Println(name)
}

Recognize manifests and compiler configuration

Go

go.mod names the module and records dependency/language requirements. go.sum records dependency checksums; it is not a lockfile that freezes every selected version in the same way as npm’s lockfile.

Fragment

go.mod example; not Go source. Go 1.23 is sufficient for the reference’s Go examples.

main.go
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
module example.com/guide

go 1.23

Recognize dependency commands

Go

Standard-library imports need no go get. go get manages module dependencies; go mod tidy reconciles requirements with the packages used by the module. Module paths and package names need not be identical.

Fragment

Shell command in a Go module; third-party requirements follow that project’s chosen module paths/versions.

main.go
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
# Standard library: import "strings"

# Reconcile go.mod/go.sum with imports:
go mod tidy