Added NewFeed()

This commit is contained in:
Jason Streifling 2024-03-05 17:05:44 +01:00
parent 9d8cc64645
commit c8551159fe

12
rss.go
View File

@ -185,11 +185,6 @@ func (c *Channel) check() error {
} }
func (f *Feed) check() error { func (f *Feed) check() error {
f = &Feed{
Version: "2.0",
ContentNamespace: "http://purl.org/rss/1.0/modules/content/",
}
if f.Channels == nil { if f.Channels == nil {
return fmt.Errorf("error: feed has no channels") return fmt.Errorf("error: feed has no channels")
} }
@ -203,6 +198,13 @@ func (f *Feed) check() error {
return nil return nil
} }
func NewFeed() *Feed {
return &Feed{
Version: "2.0",
ContentNamespace: "http://purl.org/rss/1.0/modules/content/",
}
}
func (f *Feed) ToXML() (string, error) { func (f *Feed) ToXML() (string, error) {
if err := f.check(); err != nil { if err := f.check(); err != nil {
return "", fmt.Errorf("error checking RSS feed: %v", err) return "", fmt.Errorf("error checking RSS feed: %v", err)