A Go package for parsing RSS feeds asynchronously from multiple URLs.
Overview
This package provides functionality to parse RSS feeds from multiple URLs concurrently and return structured data. It uses the latest stable version of Go and follows Go best practices.
Features
- Asynchronous RSS feed parsing from multiple URLs
- Structured RSS item data with all essential fields
- Comprehensive test coverage
API
Types
type RssItem struct {
Title string
Source string
SourceURL string
Link string
PublishDate time.Time
Description string
}
Methods
func Parse(ctx context.Context, urls []string) ([]RssItem, error)
- Parameters:
ctx - context for cancellation and timeout; urls - Array of RSS feed URLs to parse
- Returns: Array of
RssItem structs generated from all provided RSS posts
- Behavior: Parses feeds asynchronously for better performance
Requirements
Installation
go get github.com/yourusername/RssReader
Usage
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/yourusername/RssReader"
)
func main() {
ctx := context.Background()
urls := []string{
"https://example.com/feed.xml",
"https://another-blog.com/rss",
}
items, err := RssReader.Parse(ctx, urls)
if err != nil {
log.Fatal(err)
}
for _, item := range items {
fmt.Printf("Title: %s\n", item.Title)
fmt.Printf("Source: %s\n", item.Source)
fmt.Printf("Published: %s\n", item.PublishDate.Format(time.RFC3339))
fmt.Printf("Link: %s\n", item.Link)
fmt.Printf("---\n")
}
}
Development
Prerequisites
Running Tests
go test ./...
Running Linter
golangci-lint run
Running Security Checks
gosec ./...
All Checks
make all
Project Structure
RssReader/
├── README.md
├── go.mod
├── go.sum
├── .github/
│ └── workflows/
│ └── ci.yml
├── .golangci.yml
└── rssreader.go
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
MIT
Testing
All changes must be covered with tests. The project includes:
- Unit tests for all exported functions
- Integration tests for RSS parsing
- Benchmark tests for performance validation
Run the full test suite with:
go test -v -race -cover ./...