From ec2233e894245aa963598dcc4f7e144a4c6c3192 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Mon, 21 Mar 2022 20:45:27 +0900 Subject: Avoid panic on spelling inconsistencies errors close #5 --- spec/spec.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'spec/spec.go') 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) } -- cgit v1.2.3