错误

Errors 错误

原文:https://go.dev/ref/spec#Errors

The predeclared type error is defined as

​ 预先声明的error类型被定义为

1
2
3
type error interface {
	Error() string
}

It is the conventional interface for representing an error condition, with the nil value representing no error. For instance, a function to read data from a file might be defined:

​ 它是代表错误条件的常规接口,nil值代表没有错误。例如,可以定义一个从文件中读取数据的函数:

1
func Read(f *File, b []byte) (n int, err error)
最后修改 March 10, 2024: 更新 (ddf4687)