rss

package module
v0.0.0-...-fa38e8c Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: GPL-3.0 Imports: 9 Imported by: 2

README

This package provides basic support for RSS/RDF/Atom feeds. Specifically it provides functions for parsing XML as one of these formats, and for writing out feeds as RSS 2.0.

I use it in an RSS reader, gorse.

It is basic and not overly strict. My use case is to get the minimum amount of information about items in feeds, such as titles, URLs, and descriptions.

Documentation

Overview

Package rss provides helper function for interacting with RSS, RDF, and Atom feeds. Primarily this surrounds building and reading/parsing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetVerbose

func SetVerbose(verbose bool)

SetVerbose controls the package setting 'Verbose'.

func WriteFeedXML

func WriteFeedXML(feed Feed, filename string) error

WriteFeedXML takes a Feed and generates and writes an XML file.

This function generates RSS 2.0.1.

See http://www.rssboard.org/rss-specification

You can validate the output files using: http://www.rssboard.org/rss-validator

Overall the XML structure is: <rss><channel><item></item><item></item>...</channel></rss>

A note on timestamps: The RSS spec says we should use RFC 822, but the time.RFC1123Z format looks closest to their examples, so I use that.

Types

type Config

type Config struct {
	// Control whether we have verbose output (or not).
	Verbose bool
}

Config controls package wide settings.

type Feed

type Feed struct {
	Title       string
	Link        string
	Description string
	PubDate     time.Time
	Items       []Item
	Type        string
}

Feed contains information about a feed.

func ParseFeedXML

func ParseFeedXML(data []byte) (*Feed, error)

ParseFeedXML takes a feed's raw XML and returns a struct describing the feed.

We support various formats: RSS, RDF, Atom. We try our best to decode the feed in one of them.

type Item

type Item struct {
	Title       string
	Link        string
	Description string
	PubDate     time.Time
	GUID        string
}

Item contains information about an item/entry in a feed.

Jump to

Keyboard shortcuts

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