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.
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
var keyword buf your variable bytes the package what you imported.Buffer a type it declares usable as it stands
| Package | Description |
|---|---|
| fmt | Formatted I/O: printing, building strings, and reading input |
| strings | String manipulation |
| slices | Generic operations over slices |
| bytes | Byte slice manipulation |
| unicode | Unicode character classification and case conversion |
| io | Reader, Writer, and the primitives built on them |
| bufio | Buffered I/O and line/word/rune scanning |
| os | Files, environment variables, and process state |
| math | Basic math functions and constants |
| time | Instants, durations, timers, and tickers |
| sort | Sorting slices and user-defined collections |
| strconv | Conversions between strings and basic types |
| cmp | Ordering and comparison helpers for generic code |
| regexp | Regular expressions |
| sync | Mutexes, WaitGroups, and other concurrency primitives |
| context | Cancellation, deadlines, and request-scoped values |
| errors | Wrapping, checking, and comparing errors |
| net/http | HTTP client and server |
| text/template | Data-driven text generation |
| html/template | Context-aware, auto-escaping HTML templating |
| crypto | The Hash interface shared by every hashing subpackage |
| encoding/json | JSON encoding and decoding |
| net | Low-level networking |
| log | Logging |
| database/sql | SQL database access |
| flag | Command-line flag parsing |
| path/filepath | File path manipulation |
| reflect | Runtime type introspection |
| runtime | Scheduler and runtime information |
| testing | Writing and running tests |
A few functions to start with
| Function | Description |
|---|---|
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 |