Skip to content

Commit 7b5af1d

Browse files
committed
new migration helpers for marginal cases
1 parent 9924243 commit 7b5af1d

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

scripts/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ successfully from type variables (see below) to Go generics API.
99
This readme will guide you to use auto-migration scripts when ever we deprecate
1010
functions or make something obsolete.
1111

12-
### Auto-Migration of v0.9.40
12+
### Auto-Migration of v0.9.40 & v0.9.41
1313

1414
The version 0.9.40 is a major update because of the performance and API change.
1515
We have managed to eliminate `defer` slowdown. Our benchmarks are 3x faster than
@@ -52,7 +52,11 @@ Follow these steps:
5252
1. Use `git diff` or similar to skimming that all changes seem to be OK. Here
5353
you have an opportunity to start use new features of `err2` like logging.
5454
1. You are ready to commit changes.
55-
55+
1. *Problem solving tip.* Use following command to search helper functions:
56+
```shell
57+
migr-name.sh -h todo_catch
58+
migr-name.sh -h repl_catch
59+
```
5660
#### Manual Migration With a Location List
5761

5862
Follow these steps check do you have migration needs for v0.9.40:

scripts/functions.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,33 @@ repl_handle_func() {
475475
}
476476

477477
search_catch_multi='(^\s*)(defer err2\.Catch\(func\(err error\) \{)([\s\S]*?)(^\s*\}\)$)'
478+
search_catch_multi_with_panic_handler='(^\s*)(defer err2\.Catch\(func\(err error\) \{)([\s\S]*?)(^\s*\}, func\()(\w* any\) \{)'
479+
# '^\s*\}, func\(\w* any\) \{' 1 2 3 4 5
480+
481+
# --- make Catch panic easier
482+
# '^\s*\}, func\(\w* interface\{\}\) \{'
483+
search_catch_old_signature='(^\s*\}, func\(\w* )(interface\{\})(\) \{)'
484+
# 1 2 3
485+
486+
todo_catchold_sig() {
487+
vlog "searching old Catch panic handler signatures"
488+
ag "$search_catch_old_signature"
489+
}
490+
491+
repl_catchold_sig() {
492+
vlog "replacing old Catch panic handler signatures"
493+
check_commit "$search_catch_old_signature" '\1any\3'
494+
}
495+
496+
todo_catchp_func() {
497+
vlog "searching old error Catchers"
498+
ag "$search_catch_multi_with_panic_handler"
499+
}
500+
501+
repl_catchp_func() {
502+
vlog "replacing old error Catchers with panic"
503+
check_commit "$search_catch_multi_with_panic_handler" '\1defer err2.Catch(err2.Err(func(err error) {\3\1}), func(\5'
504+
}
478505

479506
todo_catch_func() {
480507
vlog "searching old error Catchers"

0 commit comments

Comments
 (0)