Constants
Variables
Discard
var Discard io.Writer = io.Discard
Discard is an io.Writer on which all Write calls succeed without doing anything.
As of Go 1.16, this value is simply io.Discard.
Discard是一个io.Writer,在它上面所有的Write调用都会成功而不做任何事情。
Functions
Types
ioutil.ReadAll
ReadAll reads from r until an error or EOF and returns the data it read. A successful call returns err == nil, not err == EOF. Because ReadAll is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.
As of Go 1.16, this function simply calls io.ReadAll.
ReadAll从r读取数据,直到出现错误或EOF,并返回它所读取的数据。一个成功的调用返回err == nil,而不是err == EOF。因为ReadAll被定义为从src读到EOF为止,所以它不把Read的EOF当作一个需要报告的错误。
从Go 1.16开始,这个函数只是调用io.ReadAll。
func ReadDir
func ReadDir(dirname string) ([]fs.FileInfo, error)
ReadDir reads the directory named by dirname and returns a list of fs.FileInfo for the directory’s contents, sorted by filename. If an error occurs reading the directory, ReadDir returns no directory entries along with the error.
ReadDir 读取由 dirname 命名的目录,并返回该目录内容的 fs.FileInfo 列表,按文件名排序。如果在读取目录时发生错误,ReadDir会返回没有目录的条目和错误。
func ReadFile
func ReadFile(filename string) ([]byte, error)
ReadFile reads the file named by filename and returns the contents. A successful call returns err == nil, not err == EOF. Because ReadFile reads the whole file, it does not treat an EOF from Read as an error to be reported.
ReadFile 读取以文件名命名的文件并返回其内容。一个成功的调用返回 err == nil, 而不是 err == EOF。因为ReadFile读取的是整个文件,所以它不把来自Read的EOF当作一个要报告的错误。