From 39298926028e31e6d7f917d0e175ba6311021ea2 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Tue, 15 Oct 2024 16:07:11 +0200 Subject: [PATCH] Check first if there are any extension elements before checking them individually --- person.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/person.go b/person.go index 4e51be6..bf947bd 100644 --- a/person.go +++ b/person.go @@ -18,9 +18,11 @@ func (p *Person) Check() error { return errors.New("name element of person element empty") } - for i, e := range p.Extensions { - if err := e.Check(); err != nil { - return fmt.Errorf("extension element %v of person %v: %v", i, p.Name, err) + if p.Extensions != nil { + for i, e := range p.Extensions { + if err := e.Check(); err != nil { + return fmt.Errorf("extension element %v of person %v: %v", i, p.Name, err) + } } }