JS Blog Software development, entertainment, lifestyle.


One-liner for serving static files in Go explained


Whenever I want to set up a server for serving static files in Go, which is not often, I always have to spend some time to figure out the following one-liner. http.Handle("/images/", http.StripPrefix("/images/", http.FileServer(http.Dir("./images")))) What confuses me probably the most here is all three strings being practically the same. So in this post I will explain what this does for my...

Error handling in concurrent programs in Golang


Error handling in concurrent programs in Go consists of little more work than if err != nil { return err } because the return value doesn’t reach intended receiver (for example in parent function where function was fired as a goroutine using go keyword). Just as we use channel for sending resulting data, we must also use channel for sending error. And we can do this using single channel of...

Libraries over frameworks


Lately (in term of years) I noticed I prefer using libraries over frameworks. Or in other words I like to use packages that each do their one thing well rather than one package with all batteries included. I recognize both libraries and frameworks have their pros and cons. You can see my preference for libraries if you are reading my blog where I write a lot about web development, specifically...

Context package in Golang


Go has a package named context in its standard library. It’s responsibilities are cancelations and carrying request-scoped data (but that doesn’t mean it’s only used in HTTP handlers). I’ve learned it in two parts. For a long time I used it only for storing request-scoped data in HTTP middlewares, but recently I’ve learned the rest of it – (1) how to set up...

A Movie Downloader (a weekend project in Go)


Last weekend’s project I made was a CLI downloader, named A Movie Downloader (movie-dl), that searches for a movie and downloads both magnet link and a matching English subtitles. A magnet is then opened with Transmission that handles its download. Subtitles are placed in a folder where a movie will be downloaded. That meant that somehow I needed to figure it out where and how this folder...

JS Blog Software development, entertainment, lifestyle.

About me

Jernej Sila portrait
Hi, I'm Jernej, a software engineer from Slovenia. Welcome to my personal blog. For more about me, my work and hobbies, please visit my profile page.