Added pointer checks to check() functions
This commit is contained in:
parent
6cd08bb65d
commit
524bf96761
25
rss.go
25
rss.go
@ -142,17 +142,36 @@ func (s *Source) check() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Content) check() error {
|
||||
if len(c.Value) == 0 {
|
||||
return fmt.Errorf("error: value not set")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *Item) check() error {
|
||||
if len(i.Title) == 0 && len(i.Description) == 0 {
|
||||
return fmt.Errorf("error: neither title nor description set")
|
||||
}
|
||||
|
||||
if i.Enclosure != nil {
|
||||
if err := i.Enclosure.check(); err != nil {
|
||||
return fmt.Errorf("error checking enclosure: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if i.Source != nil {
|
||||
if err := i.Source.check(); err != nil {
|
||||
return fmt.Errorf("error checking source: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if i.Content != nil {
|
||||
if err := i.Content.check(); err != nil {
|
||||
return fmt.Errorf("error checking content: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -168,12 +187,17 @@ func (c *Channel) check() error {
|
||||
return fmt.Errorf("error: description not set")
|
||||
}
|
||||
|
||||
if c.Image != nil {
|
||||
if err := c.Image.check(); err != nil {
|
||||
return fmt.Errorf("error checking image: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if c.TextInput != nil {
|
||||
if err := c.TextInput.check(); err != nil {
|
||||
return fmt.Errorf("error checking textInput: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
for _, item := range c.Items {
|
||||
if err := item.check(); err != nil {
|
||||
@ -188,7 +212,6 @@ func (f *Feed) check() error {
|
||||
if f.Channels == nil {
|
||||
return fmt.Errorf("error: feed has no channels")
|
||||
}
|
||||
|
||||
for _, channel := range f.Channels {
|
||||
if err := channel.check(); err != nil {
|
||||
return fmt.Errorf("error checking channel: %v", err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user