Inspiration

Have you ever been ssh'd into the CS department lab computers and thought to yourself, "I really wish I were browsing animated gifs on my phone right now"? I certainly have. But it's always felt a little awkward to be laughing at memes on your phone while everyone else around is thoughtfully engaged in their work. That is, until now. With the power of GoPhy, you don't have to choose between your phone screen and your terminal session, at least when it comes to viewing animated gifs.

What it does

Pulls in gifs from online gif repository Giphy, renders them as plain text, and iterates through their frames concurrently inside a terminal window. In addition to all this concurrent gif processing and rendering, it also listens for user input on the keyboard and moves the entered text from wherever it was on the terminal to a neat little pseudo text box element.

How I built it

Implemented entirely in the Go standard library. All formatting accomplished with ANSI escape sequences. Uses the Giphy API to pull in a collection of gifs related to a user search term.

Challenges I ran into

Concurrency is really very extremely challenging, even in a language built especially for concurrency. The first-orderness of Go's concurrency even proved to be a special challenge at times, as I was fooled into thinking certain behaviors would come about naturally when in fact I was sitting on several deadlocks.

Accomplishments that I'm proud of

It renders GIFs at all, and doesn't crash when you press an arrow key. There was a solid 4 hour period in the middle of the night where these were not the case, and I'm glad I was able to move past that.

What I learned

I had initially associated the tagline "fearless concurrency" with Go, but it turns out I was mixed up with Rust. Concurrency in Go is actually quite fearful. Nevertheless, it leads to some powerful paradigms that simply can't be accomplished in a sequential manner. The first time I was able to successfully run a series of gif downloads asynchronously, and then display them simultaneously, I was blown away.

What's next for GoPhy

First, a complete rewrite of the awful global-variable oriented data structure, and revisiting some core Go concepts. Then, an instant messenger. A Reddit client. A gif creator, even? The possibilities are endless with the power of gifs in your tty.

Built With

Share this project:

Updates