aboutsummaryrefslogtreecommitdiff
path: root/spec/spec.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2022-03-21 20:45:27 +0900
committerRyo Nihei <nihei.dev@gmail.com>2022-03-21 21:05:47 +0900
commitec2233e894245aa963598dcc4f7e144a4c6c3192 (patch)
treec9856583acaa1284e6d9685293c0a4ae2eb7e598 /spec/spec.go
parentUpdate README (diff)
downloadtre-ec2233e894245aa963598dcc4f7e144a4c6c3192.tar.gz
tre-ec2233e894245aa963598dcc4f7e144a4c6c3192.tar.xz
Avoid panic on spelling inconsistencies errors
close #5
Diffstat (limited to 'spec/spec.go')
-rw-r--r--spec/spec.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/spec/spec.go b/spec/spec.go
index 3d46269..28d5abc 100644
--- a/spec/spec.go
+++ b/spec/spec.go
@@ -256,10 +256,12 @@ func findSpellingInconsistenciesErrors(ids []string, hook func(ids []string) err
var errs []error
for _, dup := range duplicated {
- err := hook(dup)
- if err != nil {
- errs = append(errs, err)
- continue
+ if hook != nil {
+ err := hook(dup)
+ if err != nil {
+ errs = append(errs, err)
+ continue
+ }
}
var b strings.Builder
@@ -267,7 +269,7 @@ func findSpellingInconsistenciesErrors(ids []string, hook func(ids []string) err
for _, id := range dup[1:] {
fmt.Fprintf(&b, ", %+v", id)
}
- err = fmt.Errorf("these identifiers are treated as the same. please use the same spelling: %v", b.String())
+ err := fmt.Errorf("these identifiers are treated as the same. please use the same spelling: %v", b.String())
errs = append(errs, err)
}