Introduction to go common packages

1. The Go standard library can be roughly classified as follows according to the functions of the library

input Output. This category includes input and
output of binary and text formats on screens, keyboards, files, and other devices , such as reading and writing binary files. The packages corresponding to this category include bufio, fmt, io, log, and flag
, among which flag is used to process command line parameters.
Text processing. This category includes the processing of string and text content, such as character encoding conversion.
The packages corresponding to this category include encoding, bytes, strings, strconv, text, mime, unicode, regexp,
index, path, etc. The path is used to process the path string.
The internet. This category includes packages needed to develop network programs, such as Socket programming and website development.
The packages corresponding to this category are: net, http, expvar, etc.
system. This category includes the encapsulation of system functions, such as interaction with the operating system and atomic operations. To
be classified in this package has os, syscall, sync, time and the like unsafe.
Data Structures and Algorithms. The packages corresponding to this category are math, sort, container, crypto, hash,
archive, compress and image. Because the image encoding and decoding provided in the image package are all algorithms, they are also
included in this category.
Runtime. The packages corresponding to this category are: runtime, reflect, go, etc.
2. Introduction to commonly used packagesHere
are some packages that are relatively frequently used in the Go language standard library (as follows):

fmt. It implements formatted input and output operations, among which fmt.Printf() and fmt.Println() are the
most frequently used functions by developers.
io. It implements a series of non-platform-related IO-related interfaces and implementations, such as providing
encapsulation of system-related IO functions in os . We usually use this package when we perform streaming read and write (such as reading and writing files).
bufio. It provides a caching function on the basis of io. With the cache function, bufio can
provide operations such as ReadLine more conveniently .
strconv. This package provides the ability to convert between character strings and basic data types.
os. This package provides non-platform-related access interfaces to operating system functions. The interface is Unix style. The functions provided
include file operations, process management, signals, and user accounts.
sync. It provides basic synchronization primitives. When multiple goroutines access shared resources,
the lock mechanism provided in sync needs to be used .
flag. It provides the rule definition of command line parameters and the function of parsing incoming parameters. Most command line programs
need to use this package.
encoding/json. JSON is currently widely used as a communication format in network programs. This package provides basic
support for JSON , such as serializing an object into a JSON string, or deserializing a specific
object from a JSON string .
http. It is a powerful and easy-to-use package, and it is the best proof that Golang is an "Internet language". Through
the http package, a crawler or a web server can be realized with only a few lines of code, which
is unimaginable in traditional languages .

Third, the complete package list

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/Fengfgg/article/details/114096742