Documentation
¶
Overview ¶
Package rss provides a simple client for fetching and parsing RSS feeds using Go's standard libraries. It supports configurable HTTP client options such as custom timeouts or custom HTTP clients. The package includes a basic RSS struct that represents the typical XML structure of an RSS feed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶ added in v1.1.0
type Channel struct {
Title string `xml:"title"`
Link string `xml:"link"`
Description string `xml:"description"`
Language string `xml:"language"`
Image *Image `xml:"image"`
Items []Item `xml:"item"`
}
Channel represents an RSS channel.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used for fetching and parsing RSS feeds.
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
NewClient creates a new RSS Client with optional configuration options. By default, it uses an HTTP client with a 10-second timeout.
type ClientOption ¶ added in v1.1.0
type ClientOption func(*Client)
ClientOption defines a function type for configuring the RSS Client.
func WithHTTPClient ¶ added in v1.1.0
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient sets a custom HTTP client for the RSS Client.
func WithTimeout ¶ added in v1.1.0
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets a custom timeout for HTTP requests.
type Enclosure ¶ added in v1.1.0
type Enclosure struct {
URL string `xml:"url,attr"`
Type string `xml:"type,attr"`
Length string `xml:"length,attr"`
}
Enclosure represents a media enclosure in an RSS item.
type Item ¶ added in v1.1.0
type Item struct {
Title string `xml:"title"`
Link string `xml:"link"`
Description string `xml:"description"`
PubDate string `xml:"pubDate"`
GUID string `xml:"guid"`
Author string `xml:"author"`
Category string `xml:"category"`
Enclosure *Enclosure `xml:"enclosure"`
}
Item represents an RSS item.
func (*Item) GetEnclosureURL ¶ added in v1.1.0
GetEnclosureURL returns the enclosure URL if present, empty string otherwise.
func (*Item) IsImageEnclosure ¶ added in v1.1.0
IsImageEnclosure returns true if the enclosure is an image type.
func (*Item) ParsePubDate ¶ added in v1.1.0
ParsePubDate attempts to parse the PubDate field into a time.Time. Returns the parsed time or the current time if parsing fails.