From 6a76bdc0c365c9b9be2805f60e0c27dc9f428054 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Wed, 16 Oct 2024 18:41:42 +0200 Subject: [PATCH] Small changes --- source.go | 68 ++++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/source.go b/source.go index 1d271cd..f17896f 100644 --- a/source.go +++ b/source.go @@ -12,99 +12,89 @@ type Source struct { ID *ID `xml:"id,omitempty"` Links []*Link `xml:"link,omitempty"` Logo *Logo `xml:"logo,omitempty"` - Rights *Text `xml:"rights,omitempty"` - Subtitle *Text `xml:"subtitle,omitempty"` - Title *Text `xml:"title,omitempty"` + Rights Text `xml:"rights,omitempty"` + Subtitle Text `xml:"subtitle,omitempty"` + Title Text `xml:"title,omitempty"` Updated *Date `xml:"updated,omitempty"` Extensions []*ExtensionElement `xml:",any,omitempty"` } func (s *Source) Check() error { - if s.Authors != nil { - for i, a := range s.Authors { - if err := a.Check(); err != nil { - return fmt.Errorf("author element %v of source: %v", i, err) - } + for i, a := range s.Authors { + if err := a.Check(); err != nil { + return fmt.Errorf("author element %v of source %v: %v", i, s.ID.URI, err) } } - if s.Categories != nil { - for i, c := range s.Categories { - if err := c.Check(); err != nil { - return fmt.Errorf("category element %v of source: %v", i, err) - } + for i, c := range s.Categories { + if err := c.Check(); err != nil { + return fmt.Errorf("category element %v of source %v: %v", i, s.ID.URI, err) } } - if s.Contributors != nil { - for i, c := range s.Contributors { - if err := c.Check(); err != nil { - return fmt.Errorf("contributor element %v of source: %v", i, err) - } + for i, c := range s.Contributors { + if err := c.Check(); err != nil { + return fmt.Errorf("contributor element %v of source %v: %v", i, s.ID.URI, err) } } if s.Generator != nil { if err := s.Generator.Check(); err != nil { - return fmt.Errorf("generator element of source: %v", err) + return fmt.Errorf("generator element of source %v: %v", s.ID.URI, err) } } if s.Icon != nil { if err := s.Icon.Check(); err != nil { - return fmt.Errorf("icon element of source: %v", err) + return fmt.Errorf("icon element of source %v: %v", s.ID.URI, err) } } if s.ID != nil { if err := s.ID.Check(); err != nil { - return fmt.Errorf("id element of source: %v", err) + return fmt.Errorf("id element of source %v: %v", s.ID.URI, err) } } - if s.Links != nil { - for i, l := range s.Links { - if err := l.Check(); err != nil { - return fmt.Errorf("link element %v of source: %v", i, err) - } + for i, l := range s.Links { + if err := l.Check(); err != nil { + return fmt.Errorf("link element %v of source %v: %v", i, s.ID.URI, err) } } if s.Logo != nil { if err := s.Logo.Check(); err != nil { - return fmt.Errorf("logo element of source: %v", err) + return fmt.Errorf("logo element of source %v: %v", s.ID.URI, err) } } if s.Rights != nil { - if err := (*s.Rights).Check(); err != nil { - return fmt.Errorf("rights element of source: %v", err) + if err := s.Rights.Check(); err != nil { + return fmt.Errorf("rights element of source %v: %v", s.ID.URI, err) } } if s.Subtitle != nil { - if err := (*s.Subtitle).Check(); err != nil { - return fmt.Errorf("subtitle element of source: %v", err) + if err := s.Subtitle.Check(); err != nil { + return fmt.Errorf("subtitle element of source %v: %v", s.ID.URI, err) } } if s.Title != nil { - if err := (*s.Title).Check(); err != nil { - return fmt.Errorf("title element of source: %v", err) + if err := s.Title.Check(); err != nil { + return fmt.Errorf("title element of source %v: %v", s.ID.URI, err) } } if s.Updated != nil { if err := s.Updated.Check(); err != nil { - return fmt.Errorf("updated element of source: %v", err) + return fmt.Errorf("updated element of source %v: %v", s.ID.URI, err) } } - if s.Extensions != nil { - for i, e := range s.Extensions { - if err := e.Check(); err != nil { - return fmt.Errorf("extension element %v of source: %v", i, err) - } + for i, e := range s.Extensions { + if err := e.Check(); err != nil { + return fmt.Errorf("extension element %v of source %v: %v", i, s.ID.URI, err) } }