Creating an RSS Reader (listener?) because I was bored. Day 1.
I like learning programming languages, but it's been a while since I've learnt something fresh because of college, and my job and my personal life in general. And that's why I've created this blog, that way I'll feel obligated to post something every once in a while.
Recently I've been watching a lot of content in new programming languages like Zig, Rust, Elixir (vai brazilian!), but the one lang stood out from the herd because of usage and it's simplicity, Golang. So... since I need to create content for this blog and since I've been postponing learning it for a while... Let's build an RSS Feed reader/listener (for my favorite podcasts) with Go and I think I'll be using Astro with React for the frontend since I want to learn react-native and I'd like to use this app on my phone.
"Why not just use a time tested feed that won't break and will worked easily out of the box?" - Because there's no fun in that.
I've never even wrote a hello world in Go, nor created or used an RSS Feed, nor worked with Astro, or audio streaming, this is gonna be great!
Day 1 - What is RSS? and installing Go
RSS is a web feed that standardizes the access to updates on websites, allowing users to consume it using a reader/aggregator. This allows you to create a feed with only content from sources that interest you. It's been used for a long time, and it's last major version dates back to 2002.
It's basically an URL that serves a plain text in XML format. Here's an example
<?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0"> <channel> <title>RSS Title</title> <description>This is an example of a basic RSS Feed</description> <link>http://somelink.com</link> <copyright>2024 Example, All rights reserved</copyright> <lastBuildDate>Mon, 29 Sep 2024 00:01:00 +0000</lastBuildDate> <pubDate>Sun, 15 Sep 2019 16:20:00 +0000</pubDate> <ttl>1800</ttl> <item> <title>Item title</title> <description>Item description</description> <link>https://jgabriel.dev.br</link> <guid isPermaLink="false">7bd204c6-1655-4c27-aeee-53f933c5395f</guid> <pubDate>Sun, 29 Sep 2024 4:20:00 +0000</pubDate> </item> </channel> </rss>
Ok, so what I want is a way to get this and show to users. But there's more, I want to put podcasts here and get the audio to run in a player. I could do this with only client side code but I want to practice Go, so we're going the hard way.
I guess I'll end the day by installing the Go tooling and try to write a basic hello world program. And later tomorrow I'll try to think about how I'll approach this solution.
Installing Go on linux is as simple as downloading the .tar.gz and unpacking on /usr/local:
wget https://go.dev/dl/go1.23.1.linux-amd64.tar.gz && sudo tar -C /usr/local -xzf go1.23.1.linux-amd64.tar.gz
According to the official documentation, we'll firstly initiate a module in a go.mod file that will manage my dependencies (already better than tracking dependencies in a .txt file). First you run go init package-name/example and then create a dot go file and run the code.
package main import "fmt" func main() { fmt.Println("Hello, World!") }
This is what the basic hello world looks like in Go. And to run this we just call go run . and voilà:
~/Documentos/Projects/hello-go ───────────────────────────── ❯ go run . Hello, World!
Easy enough, I liked it.
Later I'll be designing the app architecture, and see what awaits for me.