Skip to content

nil error always fail at err != nil check #32

Description

@meetme2meat

Following is the sample code the output would say a lot here. I tried debugging this myself but unable to find why the behavior is such.

func main() {
	err := DBErr()
	if err != nil {
		fmt.Printf("Main err was not nil %T %v\n", err, err)
	} else {
		fmt.Println("Main", "err was nil")
	}
}

func DBErr() error {
	e := errors.Wrap(nil, 1)
	fmt.Println("DBErr() err is nil", e == nil)
	return e
}

Output:

DBErr() err is nil true
Main err was not nil *errors.Error <nil>

running go version

go version go1.16 darwin/amd64

following is my go.mod definition

module test-errors

go 1.16

require github.com/go-errors/errors v1.2.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions