1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

errors.Warpf => xerrors.Errorf全置換正規表現

Last updated at Posted at 2021-07-21

vscodeでいきなり すべて置換 を選ぶと $1 が変な結果になるので1件ずつ確認しながら実行してください。

search : errors.Wrapf\(err,\s"([^"]+)"\)
replace: xerrors.Errorf("$1: %w",err)

結果:

go
return errors.Warpf(err, "failed to xxx")
=>return  xerrors.Errorf("failed to xxx: %w", err)
search :errors.Wrapf\(err,\s`([^`]+)`\)
replace: xerrors.Errorf(`$1: %w`,err)

結果:

go
return errors.Warpf(err, `failed to xxx("cccc")`)
=>return  xerrors.Errorf(`failed to xxx("ccc"): %w`, err)
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?