-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel.go
45 lines (42 loc) · 1.61 KB
/
channel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package rss2
import (
"encoding/xml"
"fmt"
)
// Channel represents an rss channel element. Title, Link and
// Description are required.
type Channel struct {
XMLName xml.Name `xml:"channel"`
Title string `xml:"title"`
Link string `xml:"link"`
Description string `xml:"description"`
Language string `xml:"language,omitempty"`
Copyright string `xml:"copyright,omitempty"`
ManagingEditor string `xml:"managingEditor,omitempty"`
WebMaster string `xml:"webMaster,omitempty"`
PubDate *RSSTime `xml:"pubDate,omitempty"`
LastBuildDate *RSSTime `xml:"lastBuildDate,omitempty"`
Categories []*Category `xml:"category,omitempty"`
Generator string `xml:"generator,omitempty"`
Docs string `xml:"docs,omitempty"`
Cloud *Cloud `xml:"cloud,omitempty"`
TTL int `xml:"ttl,omitempty"`
Image *Image `xml:"image,omitempty"`
Rating string `xml:"rating,omitempty"`
TextInput *TextInput `xml:"textInput,omitempty"`
SkipHours *SkipHours `xml:"skipHours,omitempty"`
SkipDays *SkipDays `xml:"skipDays,omitempty"`
Items []*Item `xml:"item,omitempty"`
}
// NewChannel creates a new Channel.
func NewChannel(title, link, description string) (*Channel, error) {
if len(title) == 0 || len(link) == 0 || len(description) == 0 {
return nil, fmt.Errorf(`empty string passed to NewChannel()`)
}
return &Channel{
XMLName: xml.Name{Local: `channel`},
Title: title,
Link: link,
Description: description,
}, nil
}