Categorygithub.com/dsolerh/go-rss-reader
modulepackage
0.2.0
Repository: https://github.com/dsolerh/go-rss-reader.git
Documentation: pkg.go.dev

# README

go-rss-reader

tests

The go-rss-reader package helps manage HTTP request for RSS feeds.

The principle is simple, it provides a Parse function who makes the requests to the provided URLs (concurrently for efficiency), then process each request using this XML schema for RSS feeds. The response is a slice of RSSItem which is a struct that contains the information for:

  1. Title
  2. Link
  3. Description
  4. Publish Date (Defaults to DefaultTime())
  5. Source (Defaults to the value of url's host )
  6. Source URL (Defaults to the value of url)

Note: url refers to the given url in the urls slice that you should pass to the Parse function

The dedinition for the Parse function and RSSItem can be found here and here respectively.

Install

go get -u github.com/dsolerh/go-rss-reader

Examples

As easy as:

package main
import (
    fmt

	reader "github.com/dsolerh/go-rss-reader"
)
func main() {
	urls := []string{
		"http://yournews.com/rss"
		"http://abc.com/feed",
	}
	items := reader.Parse(urls...)

    fmt.Println(items)
}

Use a default time function

package main
import (
    fmt

	reader "github.com/dsolerh/go-rss-reader"
)
func main() {
    reader.DefaultTime = time.Now // this sets the time if it's not defined on the source

	urls := []string{
		"http://yournews.com/rss"
		"http://abc.com/feed",
	}
	items := reader.Parse(urls...)

    fmt.Println(items)
}

Exclude when no publish time is present

package main
import (
    fmt

	reader "github.com/dsolerh/go-rss-reader"
)
func main() {
    reader.DefaultTime = nil // this makes the parse exclude the feeds if they don't include the `publish_time` field

	urls := []string{
		"http://yournews.com/rss"
		"http://abc.com/feed",
	}
	items := reader.Parse(urls...)

    fmt.Println(items)
}

As a result you should see a list of RSSItem so long as the given URLs are correct and they contain valid xml feeds.

License

Copyright (c) 2023-present Daniel Soler

Licensed under MIT License

# Functions

No description provided by the author

# Variables

No description provided by the author

# Structs

RSSItem is the representation of an item retrieved from an RSS feed.

# Type aliases

No description provided by the author