diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2022-03-21 20:45:27 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2022-03-21 21:05:47 +0900 |
commit | ec2233e894245aa963598dcc4f7e144a4c6c3192 (patch) | |
tree | c9856583acaa1284e6d9685293c0a4ae2eb7e598 /spec/spec.go | |
parent | Update README (diff) | |
download | tre-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.go | 12 |
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) } |