Snob - Dev Log (How it's done)
Tags: go, opensource, tutorial
Published: 2022-08-18 18:29:00

Following up on [this post](https://www.nunogois.com/blog/snob-simple-cli-that-fetches-movies-and-tv-shows-info-written-in-go-53a2/) about [Snob](https://github.com/nunogois/snob), let's dive a bit deeper on how it was done and get a better overview from a development perspective.

## Using

 - [OMDb API](http://www.omdbapi.com/) - The API that provides us the information we require;
 - [urfave/cli](https://github.com/urfave/cli) - A simple, fast, and fun package for building command line apps in Go;
 - [fatih/color](https://github.com/fatih/color) - Color package for Go;
 - [spf13/viper](https://github.com/spf13/viper) - Go configuration with fangs;
 - [GoReleaser](https://goreleaser.com/) - Deliver Go binaries as fast and easily as possible;

## Overview

Snob is written in [Go](https://go.dev/) - If you're not familiar with Go, I suggest checking out its [docs](https://go.dev/doc/).

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](https://github.com/nunogois/snob/blob/main/snob.go) - The main entry file. The best way of understanding what it's doing is to read the [urfave/cli docs](https://cli.urfave.org/);
 - [api.go](https://github.com/nunogois/snob/blob/main/api.go) - Handles our main request to the [OMDb API](http://www.omdbapi.com/) using a key that can be set by the user. Also includes types for the result;
 - [config.go](https://github.com/nunogois/snob/blob/main/config.go) - Handles the configuration part (in our case, the key environment variable) with help from [Viper](https://github.com/spf13/viper);
 - [printer.go](https://github.com/nunogois/snob/blob/main/printer.go) - Handles printing (showing) information to the user. This is where [fatih/color](https://github.com/fatih/color) is being used, so we can print pretty information with colors.
 - [utils.go](https://github.com/nunogois/snob/blob/main/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](https://goreleaser.com/). I suggest checking out its [docs](https://goreleaser.com/intro/) and then taking a look at these files in the project:

 - [.goreleaser.yml](https://github.com/nunogois/snob/blob/main/.goreleaser.yml) - GoReleaser config file. You might notice a **brews** section that keeps the Homebrew formula updated in [nunogois/homebrew-brews](https://github.com/nunogois/homebrew-brews) - This is what makes installing through `brew install nunogois/brews/snob` possible;
 - [.github/workflows/release.yml](https://github.com/nunogois/snob/blob/main/.github/workflows/release.yml) - GitHub action that triggers GoReleaser whenever a tag is pushed;

## 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!