The Go standard library is the set of packages that ship with the Go toolchain and cover the common needs of real programs: I/O, text processing, networking, HTTP, JSON, cryptography, concurrency, testing and more. Its purpose is to let you build production services with no third-party dependencies, using APIs that are stable under the Go 1 compatibility promise.
You import packages by path, for example net/http or encoding/json, and the full list is on pkg.go.dev/std.
Go was designed for networked, concurrent servers, so the library focuses on exactly that. The practical benefits are:
go build, go test and go vet understand these packages natively.The library is also versioned with the language. Recent releases added generics-based packages such as slices, maps and cmp, structured logging in log/slog, and improved HTTP routing in net/http.
| Package | Purpose |
|---|---|
fmt | Formatted printing and scanning |
errors | Creating, wrapping and inspecting errors with errors.Is and errors.As |
io, os, bufio | Readers, writers, files, buffered I/O |
strings, bytes, strconv, unicode/utf8 | Text and byte manipulation, conversions |
slices, maps, cmp | Generic helpers for slices and maps (Go 1.21+) |
sort | Sorting; prefer slices.Sort for new code |
net/http | HTTP client and server |
encoding/json, encoding/xml, encoding/csv | Data encoding |
context | Cancellation, deadlines and request-scoped values |
sync, sync/atomic | Mutexes, WaitGroup, Once, atomics |
time | Time, durations, timers |
log/slog | Structured, levelled logging (Go 1.21+) |
database/sql | Generic SQL interface; you add a driver |
testing | Unit tests, benchmarks, fuzzing |
crypto/* | Hashing, TLS, signatures, random numbers |
html/template | Context-aware HTML templating |
This uses method and wildcard patterns in ServeMux (Go 1.22+), slog for logs and encoding/json for the response. Setting ReadHeaderTimeout is a good production habit, because a bare http.ListenAndServe has no timeouts.
Concurrency primitives are part of the language (goroutines and channels) and the library (sync, context). A common pattern is a WaitGroup with a context for cancellation:
The testing package needs no framework: files ending in _test.go with functions named TestXxx run under go test, and go test -bench . and go test -fuzz use the same package.
It deliberately stays small in some areas. There is no ORM, no full web framework with middleware ecosystems, no built-in dependency injection and only the SQL interface without drivers. Extended, officially maintained packages live in the golang.org/x modules, such as x/sync, x/crypto and x/net, which are outside the Go 1 compatibility promise but are widely used. Reach for third-party code when you need something truly beyond the standard library, not by default.
Yes. net/http, encoding/json, database/sql, log/slog and html/template are enough for many production services, and Go 1.22 added method and path-parameter routing to ServeMux.
At pkg.go.dev/std, and locally with the go doc command, for example go doc net/http.Client.
It is versioned with the Go release. The Go 1 compatibility promise means programs written for Go 1 should keep compiling and working with later Go 1.x releases.
For new code prefer slices.Sort and slices.SortFunc, which are generic and type-safe. The sort package still works and is not going away.
The Go standard library gives you the building blocks of networked, concurrent software in one stable, well-documented set of packages. Use it first, add golang.org/x modules when needed, and bring in third-party libraries only for needs it does not cover.