GithubHelp home page GithubHelp logo

feedly's Introduction

TEST COVERAGE

Feedly: RSS Parser

This is a Go library for parsing RSS feeds. It includes functions for making HTTP requests to retrieve the feed, unmarshalling the response into structs, and handling errors. It also includes functions for parsing multiple feeds concurrently and specifying different error handling strategies. The library is designed to be easy to use and highly customizable.

Installation

To install this Go library, you will need to have Go installed on your system. You can then use the go get command to install the library:

go get github.com/oyamo/feedly This will download the library and install it in your $GOPATH. You can then import the library into your Go code using the following import path:

import "github.com/oyamo/feedly"

Alternatively, you can clone the repository and install the library manually:

git clone https://github.com/oyamo/feedly.git
cd rss-parser
go install

Usage

To use this Go library to parse an RSS feed, you can use the ParseFromUrl function. This function takes a single URL as input and returns the Rss struct for the feed at that URL, or an error if one occurred.

For example:

package main

import (
	"fmt"
	"github.com/oyamo/feedly"
)

func main() {
	url := "https://example.com/rss"
	rss, err := feedly.ParseFromUrl(url)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(rss)
}

You can also use the ParseMultipleFeeds function to parse multiple feeds concurrently. This function takes a slice of URLs and an error handling strategy as input, and returns a slice of FeedRes structs and any errors that occurred. The error handling strategy can be either IGNORE or ABORT, which determines how the function handles errors when parsing a feed. If the ABORT strategy is specified and an error occurs, the function cancels all other requests and returns the error.

For example:

package main

import (
	"fmt"
	"github.com/oyamo/feedly"
)

func main() {
	urls := []string{"https://example.com/rss", "https://another-example.com/rss"}
	strategy := feedly.IGNORE
	feeds, err := feedly.ParseMultipleFeeds(urls, strategy)
	if err != nil {
		fmt.Println(err)
		return
	}
	for _, feed := range feeds {
		fmt.Println(feed.Url, feed.Rss, feed.Err, feed.Code)
	}
}

This will parse the two RSS feeds concurrently and print the results for each feed. If an error occurred while parsing a feed, it will be included in the Err field of the corresponding FeedRes struct. If the IGNORE strategy was specified, the function will continue parsing the remaining feeds even if an error occurred. If the ABORT strategy was specified, the function will cancel all other requests and return the error if an error occurred while parsing a feed.

Testing

This library has a 100% test coverage. To run the automated tests for this Go library, you will need to have Go installed on your system and have the library installed in your $GOPATH. Then, you can use the go test command to run the tests:

go test github.com/oyamo/feedly

LICENSE

MIT License

Copyright (c) 2022 Oyamo Brian

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

feedly's People

Contributors

oyamo-go avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

avary

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.