HowtoGo
Home / Standard Library / Standard Library Overview
Standard Library

Standard Library Overview

Every standard library package this site documents, in one place. Packages without a link yet aren't covered here in depth; the official go doc and pkg.go.dev remain the complete reference for those.

Reading a signature
func keyword Copy name capital, so you can call it(dst Writer, src Reader) parameters name, then type(written int64, err error) results the value, then the error
Using a type the package declares
var keyword buf your variable bytes the package what you imported.Buffer a type it declares usable as it stands
PackageDescription
fmtFormatted I/O: printing, building strings, and reading input
stringsString manipulation
slicesGeneric operations over slices
bytesByte slice manipulation
unicodeUnicode character classification and case conversion
ioReader, Writer, and the primitives built on them
bufioBuffered I/O and line/word/rune scanning
osFiles, environment variables, and process state
mathBasic math functions and constants
timeInstants, durations, timers, and tickers
sortSorting slices and user-defined collections
strconvConversions between strings and basic types
cmpOrdering and comparison helpers for generic code
regexpRegular expressions
syncMutexes, WaitGroups, and other concurrency primitives
contextCancellation, deadlines, and request-scoped values
errorsWrapping, checking, and comparing errors
net/httpHTTP client and server
text/templateData-driven text generation
html/templateContext-aware, auto-escaping HTML templating
cryptoThe Hash interface shared by every hashing subpackage
encoding/jsonJSON encoding and decoding
netLow-level networking
logLogging
database/sqlSQL database access
flagCommand-line flag parsing
path/filepathFile path manipulation
reflectRuntime type introspection
runtimeScheduler and runtime information
testingWriting and running tests

A few functions to start with

FunctionDescription
fmt.Sprintf
fmt.Sprintf("%d", 42)
Formats and returns a string
strings.Split / Join
strings.Split("a,b,c", ",")
Splits a string into a slice or joins a slice into a string
slices.Sort
slices.Sort(nums)
Sorts a slice of ordered values in place
os.Getenv
os.Getenv("API_KEY")
Reads an environment variable, empty string if unset
io.Copy
io.Copy(dst, src)
Copies from src to dst until EOF
time.Now
time.Now()
Returns the current local time
errors.Is
errors.Is(err, os.ErrNotExist)
Reports whether an error chain contains a target error
regexp.MatchString
regexp.MatchString("a.*b", "acb")
Reports whether a string matches a regular expression