Skip to content

[errors] Remove use of non-standard github.com/pkg/errors #1209

@EtienneM

Description

@EtienneM

The package github.com/Scalingo/go-utils/errors/v2 makes use of the package github.com/pkg/errors so that we can call functions like errors.Wrap in the errctx.go file.

Uses of this package are:

func New(ctx context.Context, message string) error {
return ErrCtx{ctx: ctx, err: errors.New(message)}
}

func Wrap(ctx context.Context, err error, message string) error {
return ErrCtx{ctx: ctx, err: errors.Wrap(err, message)}
}

func Errorf(ctx context.Context, format string, args ...interface{}) error {
return ErrCtx{ctx: ctx, err: errors.Errorf(format, args...)}
}

The package github.com/pkg/errors is not part of the standard library. It was widely used in the Go community before Go 1.13 because there were no error wrapping mechanism in the standard library. Go 1.13 introduced a wrapping mechanism with the addition of %w in fmt.Errorf.

Hence I would be in favor of removing the using of this non-standard package to solely rely on the standard library for wrapping purpose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgoPull requests that update Go codegood first issueGood for newcomerslow

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions