Documentation ¶
Index ¶
- Constants
- type Category
- type Channel
- func (c *Channel) AddCategory(value, domain string) *Channel
- func (c *Channel) AddItem(item *Item) *Channel
- func (c *Channel) SetCopyright(copyright string) *Channel
- func (c *Channel) SetDocs(docs string) *Channel
- func (c *Channel) SetGenerator(generator string) *Channel
- func (c *Channel) SetImage(image *Image) *Channel
- func (c *Channel) SetLanguage(language string) *Channel
- func (c *Channel) SetLastBuildDate(lastBuildDate time.Time, loc *time.Location) *Channel
- func (c *Channel) SetManagingEditor(email, name string) *Channel
- func (c *Channel) SetPubDate(pubDate time.Time, loc *time.Location) *Channel
- func (c *Channel) SetTTL(ttl int) *Channel
- func (c *Channel) SetWebMaster(email, name string) *Channel
- type Enclosure
- type Feed
- type GUID
- type Image
- type Item
- func (i *Item) AddCategory(value, domain string) *Item
- func (i *Item) SetAuthor(email, name string) *Item
- func (i *Item) SetComments(comments string) *Item
- func (i *Item) SetDescription(description string) *Item
- func (i *Item) SetEnclosure(url string, length int, mimeType string) *Item
- func (i *Item) SetGUID(value string, isPermaLink bool) *Item
- func (i *Item) SetLink(link string) *Item
- func (i *Item) SetPubDate(pubDate time.Time, loc *time.Location) *Item
- func (i *Item) SetTitle(title string) *Item
Constants ¶
const (
RSSTimeFormat = "Mon, 02 Jan 2006 15:04:05 -0700"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct { // Required elements Title string `xml:"title"` Link string `xml:"link"` Description string `xml:"description"` // Optional elements Language string `xml:"language,omitempty"` Copyright string `xml:"copyright,omitempty"` ManagingEditor string `xml:"managingEditor,omitempty"` WebMaster string `xml:"webMaster,omitempty"` PubDate string `xml:"pubDate,omitempty"` LastBuildDate string `xml:"lastBuildDate,omitempty"` Generator string `xml:"generator,omitempty"` Docs string `xml:"docs,omitempty"` Categories []Category `xml:"category,omitempty"` TTL int `xml:"ttl,omitempty"` Image *Image `xml:"image,omitempty"` Items []*Item `xml:"item,omitempty"` }
func NewChannel ¶
NewChannel creates a new channel.
Title represents the name of the channel. It's how people refer to your service. If you have an HTML website that contains the same information as your RSS file, the title of your channel should be the same as the title of your website.
Link is the URL to the HTML website corresponding to the channel.
Description is the phrase or sentence describing the channel.
func (*Channel) AddCategory ¶
AddCategory specifies one or more categories that the channel belongs to. It follows the same rules as the <item>-level category element.
func (*Channel) SetCopyright ¶
SetCopyright sets the copyright notice for content in the channel.
func (*Channel) SetGenerator ¶
SetGenerator indicates the program used to generate the channel.
func (*Channel) SetImage ¶
SetImage specifies a GIF, JPEG or PNG image that can be displayed with the channel.
func (*Channel) SetLanguage ¶
SetLanguage sets the language the channel is written in.
Examples: en-us, it-it, en-gb, en-ca, fr-fr, de-de, ja-jp, zh-cn, zh-tw, etc.
func (*Channel) SetLastBuildDate ¶
SetLastBuildDate indicates the last time the content of the channel changed. The time location must be specified so the date time string can be correctly formatted according to the RSS specification.
func (*Channel) SetManagingEditor ¶
SetManagingEditor sets the email address for person responsible for editorial content.
func (*Channel) SetPubDate ¶
SetPubDate indicates when the channel was last updated. The time location must be specified so the date time string can be correctly formatted according to the RSS specification.
func (*Channel) SetTTL ¶
SetTTL specifies the number of minutes that indicates how long a channel can be cached before refreshing from the source.
func (*Channel) SetWebMaster ¶
SetWebMaster sets the email address for person responsible for technical issues relating to channel.
type Feed ¶
type Image ¶
type Image struct { // Required elements URL string `xml:"url,omitempty"` Title string `xml:"title,omitempty"` Link string `xml:"link,omitempty"` // Optional elements Width int `xml:"width,omitempty"` Height int `xml:"height,omitempty"` Description string `xml:"description,omitempty"` }
func NewImage ¶
NewImage specifies a GIF, JPEG or PNG image that can be displayed with the channel. URL is the URL of a GIF, JPEG or PNG image that represents the channel. Title describes the image, it's used in the ALT attribute of the HTML <img> tag when the channel is rendered in HTML. Link is the URL of the site, when the channel is rendered, the image is a link to the site.
func (*Image) SetDescription ¶
SetDescription specifies the text that is included in the TITLE attribute of the link formed around the image in the HTML rendering.
type Item ¶
type Item struct { // All elements of an item are optional, // however at least one of title or // description must be present. Title string `xml:"title,omitempty"` Description string `xml:"description,omitempty"` // Optional elements Link string `xml:"link,omitempty"` Author string `xml:"author,omitempty"` Comments string `xml:"comments,omitempty"` PubDate string `xml:"pubDate,omitempty"` GUID *GUID `xml:"guid,omitempty"` Enclosure *Enclosure `xml:"enclosure,omitempty"` Categories []Category `xml:"category,omitempty"` }
func NewItemWithDescription ¶
NewItemWithDescription creates an item which represents a "story" -- much like a story in a newspaper or magazine; if so its description is a synopsis of the story, and the link points to the full story. An item may also be complete in itself, if so, the description contains the text (entity-encoded HTML is allowed), and the link and title may be omitted. All elements of an item are optional, however at least one of title or description must be present.
func NewItemWithTitle ¶
NewItemWithTitle creates an item which represents a "story" -- much like a story in a newspaper or magazine; if so its description is a synopsis of the story, and the link points to the full story. An item may also be complete in itself, if so, the description contains the text (entity-encoded HTML is allowed), and the link and title may be omitted. All elements of an item are optional, however at least one of title or description must be present.
func (*Item) AddCategory ¶
AddCategory includes the item in one or more categories. More than one category may be specified by including multiple category elements.
It has one optional attribute, domain, a string that identifies a categorization taxonomy.
The value of the element is a forward-slash-separated string that identifies a hierarchic location in the indicated taxonomy. Processors may establish conventions for the interpretation of categories.
func (*Item) SetComments ¶
SetComments sets the URL of a page for comments relating to the item.
func (*Item) SetDescription ¶
SetDescription sets the item synopsis.
func (*Item) SetEnclosure ¶
SetEnclosure describes a media object that is attached to the item. It has three required attributes. url says where the enclosure is located, length says how big it is in bytes, and type says what its type is, a standard MIME type.
Example:
<enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg" />
func (*Item) SetPubDate ¶
SetPubDate indicates when the item was published. If it's a date in the future, aggregators may choose to not display the item until that date. The time location must be specified so the date time string can be correctly formatted according to the RSS specification.