Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{,x-pack/}auditbeat: replace uses of github.com/pkg/errors with stdlib equivalents #30321

Merged
merged 4 commits into from
Feb 21, 2022

Commits on Feb 10, 2022

  1. mechanical replacement of github.com/pkg/error with standard library …

    …error handling
    
    This is not completely automatable here due to some semantic differences between
    errors.Wrap and fmt.Errorf with the %w verb; the latter will convert a nil error
    into a non-nil error, so this must be guarded with a nil error check.
    
    The mechanical transformation was done by running the following commands:
    	gofmt -w -r 'errors.Errorf -> fmt.Errorf' .
    	gofmt -w -r 'errors.Wrap(e, m) -> fmt.Errorf(m+": %w", e)' .
    	gofmt -w -r 'errors.Wrapf(e, m) -> fmt.Errorf(m+": %w", e)' .
    	gofmt -w -r 'errors.Wrapf(e, m, a) -> fmt.Errorf(m+": %w", a, e)' .
    	gofmt -w -r 'errors.Wrapf(e, m, a, b) -> fmt.Errorf(m+": %w", a, b, e)' .
    	gofmt -w -r 'errors.Wrapf(e, m, a, b, c) -> fmt.Errorf(m+": %w", a, b, c, e)' .
    	find . -name '*.go' -exec gsed -i -e 's/"+": %w",/: %w",/g' '{}' \;
    	find . -name '*.go' -exec gsed -i -e 's!"github.com/pkg/errors"$!"errors"!g' '{}' \;
    	goimports -w .
    	go mod tidy
    	gofumpt -w .
    
    Replaying that will give the changes here modulo some manual changes that are
    made in the next commit. There should be no uses of %w in this change that are
    not guarded by a nil-check.
    efd6 committed Feb 10, 2022
    Configuration menu
    Copy the full SHA
    3236fdc View commit details
    Browse the repository at this point in the history
  2. manual replacement of github.com/pkg/error with standard library erro…

    …r handling
    
    This is the manual part of the change and includes some complete removal of errors
    and some silently passed bugs resulting from the use of Wrap.
    
    In one place the exact semantics of errors.Cause is implemented to fit in with a
    testing strategy.
    efd6 committed Feb 10, 2022
    Configuration menu
    Copy the full SHA
    5a53f65 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ddeb784 View commit details
    Browse the repository at this point in the history

Commits on Feb 21, 2022

  1. Configuration menu
    Copy the full SHA
    63959ea View commit details
    Browse the repository at this point in the history