In Go, the function fmt.Errorf() returns an error interface.
What's the proper way to check if fmt.Errorf() itself failed?
检查对fmt.Errorf()的调用是否失败[关闭]
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- 普通网友 2018-08-24 20:18关注
Errorfformats according to a format specifier and returns the string as a value that satisfies error. The fmt package's Errorf function lets us use the package's formatting features to create descriptive error messages.func Errorf(format string, a ...interface{}) error { return errors.New(Sprintf(format, a...)) }And
Newreturns an error that formats as the given text.func New(text string) error { return &errorString{text} }And
errorStringis a trivial implementation of error.type errorString struct { s string }So Basically what it is returning is field of string type.
解决 无用评论 打赏 举报