考虑以下关于 Go 接口和 nil 的代码,程序会输出什么?
type CustomError struct{}
func (e *CustomError) Error() string {
return "custom error"
}
func findError() error {
var e *CustomError = nil
return e
}
func main() {
err := findError()
if err != nil {
fmt.Println("error occurred")
} else {
fmt.Println("no error")
}
}
