Compare commits

...

2 Commits

Author SHA1 Message Date
1db1fcb9c8 Get rid of non-standard Content 2024-08-30 22:25:18 +02:00
c4aea5c6a6 Put XML tag on its own line 2024-04-04 17:02:20 +02:00

22
rss.go
View File

@ -35,11 +35,6 @@ type Source struct {
Value string Value string
} }
type Content struct {
XMLName xml.Name `xml:"content:encoded"`
Value string `xml:",cdata"`
}
type Item struct { type Item struct {
XMLName xml.Name `xml:"item"` XMLName xml.Name `xml:"item"`
Title string `xml:"title,omitempty"` Title string `xml:"title,omitempty"`
@ -51,7 +46,6 @@ type Item struct {
Guid string `xml:"guid,omitempty"` Guid string `xml:"guid,omitempty"`
PubDate string `xml:"pubDate,omitempty"` PubDate string `xml:"pubDate,omitempty"`
Source *Source Source *Source
Content *Content
Categories []string `xml:"category,omitempty"` Categories []string `xml:"category,omitempty"`
} }
@ -142,14 +136,6 @@ func (s *Source) check() error {
return nil 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 { func (i *Item) check() error {
if len(i.Title) == 0 && len(i.Description) == 0 { if len(i.Title) == 0 && len(i.Description) == 0 {
return fmt.Errorf("error: neither title nor description set") return fmt.Errorf("error: neither title nor description set")
@ -167,12 +153,6 @@ func (i *Item) check() error {
} }
} }
if i.Content != nil {
if err := i.Content.check(); err != nil {
return fmt.Errorf("error checking content: %v", err)
}
}
return nil return nil
} }
@ -239,5 +219,5 @@ func (f *Feed) ToXML(encoding string) (string, error) {
return "", fmt.Errorf("error XML encoding feed: %v", err) return "", fmt.Errorf("error XML encoding feed: %v", err)
} }
return `<?xml version="1.0" encoding="` + encoding + `"?>` + string(xml), nil return fmt.Sprintln(`<?xml version="1.0" encoding="`+encoding+`"?>`) + string(xml), nil
} }