Coder Social home page Coder Social logo

Comments (4)

oldme-git avatar oldme-git commented on August 17, 2024

33ad0ef30f01ba6a24eb13d139ba9b3
error.is 对应的应该是 gerror.Equal

from gf.

Issues-translate-bot avatar Issues-translate-bot commented on August 17, 2024

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


33ad0ef30f01ba6a24eb13d139ba9b3
error.is should correspond to gerror.Equal

from gf.

hailaz avatar hailaz commented on August 17, 2024
err1 := errors.New("permission denied")
fmt.Println(gerror.Is(err1, err1))// false
fmt.Println(gerror.Is(gerror.Wrap(err1, ""), err1))// 这样套一套能返回true,但有点多此一举


func Is(err, target error) bool {
	if e, ok := err.(IIs); ok {
		return e.Is(target)
	}
	return false // 这里不应该直接返回
}

from gf.

lingcoder avatar lingcoder commented on August 17, 2024
err1 := errors.New("permission denied")
fmt.Println(gerror.Is(err1, err1))// false
fmt.Println(gerror.Is(gerror.Wrap(err1, ""), err1))// 这样套一套能返回true,但有点多此一举


func Is(err, target error) bool {
	if e, ok := err.(IIs); ok {
		return e.Is(target)
	}
	return false // 这里不应该直接返回
}

对的,同一个错误,Is都返回false,挺反直觉的

from gf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.