Unit content
Go programming
Go is a statically typed, compiled programming language designed around simple syntax, explicit error handling, packages and a strong standard library.
This unit focuses on what is specific to Go rather than repeating general programming concepts such as control flow, functions and collections.
Types and declarations
Go can infer local variable types while keeping every value statically typed:
name := "Ada"
count := 3
Structs group related fields into new types:
type User struct {
Name string
Active bool
}
Slices, maps and pointers
Slices provide variable-length views over arrays, while maps associate keys with values. Pointers let code refer to an existing value without copying it, but Go does not support arbitrary pointer arithmetic.
Methods and interfaces
Methods attach behaviour to named types. Interfaces describe behaviour through method sets, and a type satisfies an interface implicitly by implementing the required methods.
Errors
Functions commonly report failure by returning an error value:
value, err := load()
if err != nil {
return err
}
Errors are ordinary values: callers decide whether to handle, wrap or propagate them.
Packages and modules
Source files belong to packages. Packages expose identifiers whose names begin with an uppercase letter, and imports make other packages available. A go.mod file defines a module and its dependencies.
Toolchain
The standard toolchain integrates common development operations:
go fmt
go test ./...
go build ./...
Go combines a small language with conventions and tooling that make package boundaries, errors and build behaviour explicit.