rss

package
v4.24.2+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2017 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package rss of the Tideland Go Library implements an RSS feed client.

The RSS package provides the RSS XML schema as Go types for the usage with the standard marshalling/unmarshalling. The supported format is RSS 2.0. A client allows to retrieve RSS documents.

Index

Constants

View Source
const (
	ErrValidation = iota + 1
	ErrParsing
)

Error codes of the RSS package.

View Source
const (
	Version = "2.0"
)

Version of the RSS.

Variables

This section is empty.

Functions

func ComposeTime

func ComposeTime(t time.Time) string

ComposeTime takes a Go time and converts it into a valid RSS time string.

func Encode

func Encode(w io.Writer, rss *RSS) error

Encode writes the RSS document to the writer.

func IsParsingError

func IsParsingError(err error) bool

IsParsingError checks if the error signals a bad formatted value.

func IsValidationError

func IsValidationError(err error) bool

IsValidationError checks if the error signals an invalid feed.

func ParseTime

func ParseTime(s string) (t time.Time, err error)

ParseTime analyzes the RSS date/time string and returns it as Go time.

Types

type Category

type Category struct {
	Category string `xml:",chardata"`
	Domain   string `xml:"domain,attr,omitempty"`
}

Category identifies a category or tag to which the feed belongs.

func (*Category) Validate

func (c *Category) Validate() error

Validate checks if the category is valid.

type Channel

type Channel struct {
	Title          string      `xml:"title"`
	Description    string      `xml:"description"`
	Link           string      `xml:"link"`
	Categories     []*Category `xml:"category,omitempty"`
	Cloud          *Cloud      `xml:"cloud,omitempty"`
	Copyright      string      `xml:"copyright,omitempty"`
	Docs           string      `xml:"docs,omitempty"`
	Generator      string      `xml:"generator,omitempty"`
	Image          *Image      `xml:"image,omitempty"`
	Language       string      `xml:"language,omitempty"`
	LastBuildDate  string      `xml:"lastBuildDate,omitempty"`
	ManagingEditor string      `xml:"managingEditor,omitempty"`
	PubDate        string      `xml:"pubDate,omitempty"`
	Rating         string      `xml:"rating,omitempty"`
	SkipDays       *SkipDays   `xml:"skipDays,omitempty"`
	SkipHours      *SkipHours  `xml:"skipHours,omitempty"`
	TextInput      string      `xml:"textInput,omitempty"`
	TTL            int         `xml:"ttl,omitempty"`
	WebMaster      string      `xml:"webMaster,omitempty"`
	Items          []*Item     `xml:"item,omitempty"`
}

Channel is the one channel element of the RSS document.

func (Channel) Validate

func (c Channel) Validate() error

Validate checks if the cannel is valid.

type Cloud

type Cloud struct {
	Domain            string `xml:"domain,attr"`
	Port              int    `xml:"port,attr,omitempty"`
	Path              string `xml:"path,attr"`
	RegisterProcedure string `xml:"registerProcedure,attr"`
	Protocol          string `xml:"protocol,attr"`
}

Cloud indicates that updates to the feed can be monitored using a web service that implements the RssCloud application programming interface.

func (*Cloud) Validate

func (c *Cloud) Validate() error

Validate checks if the cloud is valid.

type Enclosure

type Enclosure struct {
	Length int64  `xml:"length,attr"`
	Type   string `xml:"type,attr"`
	URL    string `xml:"url,attr"`
}

Enclosure associates a media object such as an audio or video file with the item.

func (*Enclosure) Validate

func (e *Enclosure) Validate() error

Validate checks if the enclosure is valid.

type GUID

type GUID struct {
	GUID        string `xml:",chardata"`
	IsPermaLink bool   `xml:"isPermaLink,attr,omitempty"`
}

GUID provides a string that uniquely identifies the item.

func (*GUID) Validate

func (g *GUID) Validate() error

Validate checks if the GUID is valid.

type Image

type Image struct {
	Link        string `xml:"link"`
	Title       string `xml:"title"`
	URL         string `xml:"url"`
	Description string `xml:"description,omitempty"`
	Height      int    `xml:"height,omitempty"`
	Width       int    `xml:"width,omitempty"`
}

Image supplies a graphical logo for the feed .

func (*Image) Validate

func (i *Image) Validate() error

Validate checks if the image is valid.

type Item

type Item struct {
	Title       string      `xml:"title,omitempty"`
	Description string      `xml:"description,omitempty"`
	Author      string      `xml:"author,omitempty"`
	Categories  []*Category `xml:"category,omitempty"`
	Comments    string      `xml:"comments,omitempty"`
	Enclosure   *Enclosure  `xml:"enclosure,omitempty"`
	GUID        *GUID       `xml:"guid,omitempty"`
	Link        string      `xml:"link,omitempty"`
	PubDate     string      `xml:"pubDate,omitempty"`
	Source      *Source     `xml:"source,omitempty"`
}

Item represents distinct content published in the feed such as a news article, weblog entry or some other form of discrete update. It must contain either a title or description.

func (*Item) Validate

func (i *Item) Validate() error

Validate checks if the item is valid.

type RSS

type RSS struct {
	XMLName string  `xml:"rss"`
	Version string  `xml:"version,attr"`
	Channel Channel `xml:"channel"`
}

RSS is the root element of the document.

func Decode

func Decode(r io.Reader) (*RSS, error)

Decode reads the RSS document from the reader.

func Get

func Get(u *url.URL) (*RSS, error)

Get retrieves an RSS document from the given URL.

func (*RSS) Validate

func (r *RSS) Validate() error

Validate checks if the RSS document is valid.

type SkipDays

type SkipDays struct {
	Days []string `xml:"day"`
}

SkipDays identifies days of the week during which the feed is not updated.

func (*SkipDays) Validate

func (s *SkipDays) Validate() error

Validate checks if the skip days are valid.

type SkipHours

type SkipHours struct {
	Hours []int `xml:"hour"`
}

SkipHours identifies the hours of the day during which the feed is not updated.

func (*SkipHours) Validate

func (s *SkipHours) Validate() error

Validate checks if the skip hours are valid.

type Source

type Source struct {
	Source string `xml:",chardata"`
	URL    string `xml:"url,attr"`
}

Source indicates the fact that the item has been republished from another RSS feed.

func (*Source) Validate

func (s *Source) Validate() error

Validate checks if the source is valid.

type TextInput

type TextInput struct {
	Description string `xml:"description"`
	Link        string `xml:"link"`
	Name        string `xml:"name"`
	Title       string `xml:"title"`
}

TextInput defines a form to submit a text query to the feed's publisher over the Common Gateway Interface (CGI).

func (*TextInput) Validate

func (t *TextInput) Validate() error

Validate checks if the text input is valid.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL