Skip to content

docs: clarify Wrapf deprecation and fmt.Errorf Go 1.13+ wrapping - #65

Open
AdamMagued wants to merge 1 commit into
hashicorp:masterfrom
AdamMagued:clarify-wrapf-doc
Open

AdamMagued wants to merge 1 commit into
hashicorp:masterfrom
AdamMagued:clarify-wrapf-doc

Conversation

@AdamMagued

Copy link
Copy Markdown

Contributor Checklist

  • LLM Usage If an LLM was used to generate any code, please ensure and confirm you have read and followed the AI usage guide.

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
  • If applicable, I've documented the impact of any changes to security controls.

Description

In errwrap.go, the docstring for Wrapf previously stated that users should replace fmt.Errorf with Wrapf, while directly below marking Wrapf as Deprecated: Use fmt.Errorf().

Additionally, README.md noted that wrapping with fmt.Errorf loses error structure, and used deprecated errwrap.Wrapf in the basic usage example.

This change:

  • Clarifies in Wrapf docstring that Go 1.13+ natively supports error wrapping via fmt.Errorf("%w", ...).
  • Removes the outdated recommendation to replace fmt.Errorf with Wrapf.
  • Updates README.md to note that prior to Go 1.13 wrapping via fmt.Errorf lost error structure, while Go 1.13+ supports native wrapping via fmt.Errorf("%w", ...).
  • Updates the basic usage example in README.md to use fmt.Errorf("%w", ...) instead of deprecated Wrapf.

Fixes #12

Update Wrapf docstring and README to clarify that Go 1.13+ supports native error wrapping via fmt.Errorf("%w", ...). Remove the outdated recommendation to replace fmt.Errorf with Wrapf, and update the basic usage example in the README to use fmt.Errorf instead of deprecated Wrapf.

Fixes hashicorp#12
@AdamMagued
AdamMagued requested review from a team as code owners October 2, 2026 21:44
@AdamMagued
AdamMagued requested a review from Romeo-Em October 2, 2026 21:44
@hashicorp-cla-app

Copy link
Copy Markdown

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


Adam Magued seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA.
If you have already a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should this doc be improved?

1 participant