Skip to content

proposal: Go 2: adopt Cause and Wrap from github.com/pkg/errors #25675

@VojtechVitek

Description

@VojtechVitek

Is there anyone else who'd like to see https://github.com/pkg/errors (or similar) being adopted in Go 2.0?

Forked from #21161 (comment).

Example:

func Chdir(dir string) error {
	if e := syscall.Chdir(dir); e != nil {
		return errors.Wrap(e, "failed to change directory")
	}
	return nil
}

Alternative one-liner example, since errors.Wrap() returns nil on nil error:

func Chdir(dir string) error {
	return errors.Wrap(syscall.Chdir(dir), "failed to change directory")
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeProposalerror-handlingLanguage & library change proposals that are about error handling.v2An incompatible library change

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions