-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3c9fff
commit da5f112
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# rss2go | ||
|
||
`rss2go` is a Go package designed to fetch and parse RSS feeds. It provides a simple API to request RSS data from a URL and unmarshals the XML content into Go structs. | ||
|
||
## Features | ||
|
||
- Fetches RSS feeds via HTTP requests | ||
- Parses and unmarshals RSS feed data from XML into Go structs | ||
- Supports media content in RSS feed items | ||
- Handles common RSS formats including Atom links | ||
- Cleans up CDATA tags from the response | ||
|
||
## Installation | ||
|
||
To use `rss2go`, you need to have Go installed. You can install the package with the following command: | ||
|
||
```bash | ||
go get github.com/gentildpinto/rss2go | ||
``` | ||
|
||
## Usage | ||
|
||
Import the package in your Go project and call the Rss2Go function to fetch and parse an RSS feed: | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/gentildpinto/rss2go" | ||
) | ||
|
||
func main() { | ||
feedUrl := "https://example.com/rss" | ||
feed, err := rss2go.Rss2Go(feedUrl) | ||
if err != nil { | ||
log.Fatalf("Error fetching feed: %v", err) | ||
} | ||
|
||
fmt.Println("Feed Title:", feed.Channel.Title) | ||
for _, item := range feed.Channel.Items { | ||
fmt.Printf("Title: %s\nLink: %s\n", item.Title, item.Link) | ||
} | ||
} | ||
``` | ||
|
||
## Structs | ||
|
||
The following Go structs are used to represent the structure of an RSS feed: | ||
|
||
- **Feed**: The root RSS element. | ||
- **Channel**: Contains metadata about the RSS feed. | ||
- **Item**: Represents each entry in the feed. | ||
- **Image**: Optional image metadata for the feed. | ||
- **MediaContent**: Represents media content (if any) in an item. | ||
- **AtomLink**: Used for Atom feed compatibility. | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Feel free to submit a pull request or open an issue if you encounter any bugs or have suggestions for new features. | ||
|
||
<!--License | ||
This project is licensed under the MIT License. See the LICENSE file for details.--> |