Nuno Góis

Snob - Dev Log (How it's done)

Snob - Dev Log (How it's done)

Aug 18 #go #opensource #tutorial

Following up on this post about Snob, let's dive a bit deeper on how it was done and get a better overview from a development perspective.

Using

  • OMDb API - The API that provides us the information we require;
  • urfave/cli - A simple, fast, and fun package for building command line apps in Go;
  • fatih/color - Color package for Go;
  • spf13/viper - Go configuration with fangs;
  • GoReleaser - Deliver Go binaries as fast and easily as possible;

Overview

Snob is written in Go - If you're not familiar with Go, I suggest checking out its docs.

This is a very simple project that can be accomplished in a couple of hours or less.

The main requirement for this project is obviously the OMDb API - Our CLI is simply a way of interfacing with it.

Project

  • snob.go - The main entry file. The best way of understanding what it's doing is to read the urfave/cli docs;
  • api.go - Handles our main request to the OMDb API using a key that can be set by the user. Also includes types for the result;
  • config.go - Handles the configuration part (in our case, the key environment variable) with help from Viper;
  • printer.go - Handles printing (showing) information to the user. This is where fatih/color is being used, so we can print pretty information with colors.
  • utils.go - Includes any utility functions, like for example calculating an average from an int array;

Looking through these files, especially starting with snob.go, should be pretty self-explanatory and provide a good understanding of what's going on.

Deployment

Deployment is provided through GoReleaser. I suggest checking out its docs and then taking a look at these files in the project:

Final Thoughts

Overall, this was a very quick and fun project. I highly recommend a project like this for beginners or anyone that wishes to practice some basics, whether it's in Go or any other language.

Like I mentioned on the previous post, I'll try to share more about some of my side projects in the future, so stay tuned for that!

I'll try to prioritise my more recent/relevant projects, or the ones that are most popular/starred - So if you like my work, feel free to engage with it in any way and star it, it's much appreciated.

Thanks for reading!

React to this blog post on DEV Community 👩‍💻👨‍💻 www.nunogois.com