Introduction to Go Standard Library
At the time of writing this article, Go's release version has reached 1.21, and it has been more than a year since this site was first established.
Go's standard library is very rich (excluding data structures) and powerful. The API is very developer-friendly. Being proficient in using the standard library will be of great help to daily development. For example, you can develop an independent and complete web project without any external dependencies, using only net/http, html/template, and database/sql.
The content of the standard library has not been updated because there is really too much content. Therefore, the following will briefly summarize the functions of some commonly used standard libraries, so you can choose the ones you are interested in to learn more. Each standard library's package-level comments will explain in detail what the package is used for.
fmt: Package for handling formatted input and outputhtml: HTML template manipulation packagenet: Provides a series of network operation packages, very powerfulflag: Command line argument parsing packagereflect: Reflection operation packagelog: Built-in logging packagesort: Sorting operation packageregex: Regular expression packageimage: Image manipulation packagetime: Time manipulation packageunicode: Unicode character set manipulation packageunsafe: Provides pointer operations without type restrictionssyscall: System call package provided by the operating systemtesting: Testing package, mainly used when writing testssync: Concurrency operation packagecontext: Context packagestrconv: String conversion packagestrings: String manipulation packagebytes: Byte slice manipulation packagemaps: Map manipulation packageslices: Slice manipulation packageio: Defines a series of basic IO interfaces, such as commonly usedCloser,Writer, etc., as well as some basic IO operation functionsio/fs: Defines a series of file system interfaces, which can be considered as an abstraction of the file systemos: Package for interacting with the operating system, providing a series of concrete functions, which can be simply understood as the concrete implementation of the above twoos/signal: Operating system signal package, used to listen for operating system signals, mainly used to achieve graceful shutdown of programsos/exec: Operating system command package, used to execute operating system commandsos/user: Operating system user package, used to obtain operating system user informationbufio: Buffered IO read and write packagepath: Package for handling slash-separated paths, such as URLspath/filepath: Package for handling file pathsmath: Mathematical operation packagemath/bits: Bitwise operation packagemath/cmplx: Complex number operation package, also provides some trigonometric function utilitiesmath/rand: Pseudo-random number packagemath/big: High-precision large number calculation packagecontainer/heap: Min-heap implementationcontainer/list: Doubly-linked list implementationcontainer/ring: Ring implementationarchive/zip: Zip compression archive packagearchive/tar: Tar archive file packagecompress: Compression algorithm implementation package, such as gzip, flatedatabase/sql: Package for interacting with databasesencoding: Package for handling encoding, with many sub-packages such asjson,xml, andbase64crypto: Package for handling encryption, with many sub-packages such as sha1, rsa, etc.go/ast: Package for mapping Go source code to abstract syntax treego/parser: Package for parsing Go source code into abstract syntax treego/importer: Provides access to importersgo/format: Go language formatting packagearena: Provides functionality for manual memory allocation and deallocation, in experimental stageruntime: Runtime operation package, many operations in Go are implemented by this package
