Tools for starting with Go

Tools for Go

Intro

I’m writing this piece of writing because I want to start documenting some special cases where I spend some time searching things and maybe these kinds of posts can help someone else.

Let’s get started

A few weeks ago, I started learning the Go language also known as Golang, so far I know the basics, and since the best way to learn is practicing, so I wanted to start building something, but before that, I desired to know some tools for the next needs:

NOTE: The below tools are based on my current setup, Visual Studio Code (VScode) as my text editor, and macOS as my operating system.

So, let’s start listing the tools that I chose!

Linter

When I started looking for a linter, I noticed that exists a linter project in Golang’s GitHub profile called lint.

However, since I’m going to be using VScode as my text editor, I found a nice extension for that and other purposes.

That extension includes some nice projects/tools for converting your VScode such as an Integrated Development Environment.

As you can see, the linter that I will be using is “staticcheck”, however in the case that you want to review some alternatives, I suggest reviewing this cool repo with a curated list of Go linters.

Snippet generator

For this, I didn’t have to spend time, because the extension mentioned above is covering that with “impl” and “go-tests” and for now, I think I’m good, however, If I find or I need more extensions for this purpose, I will update this post.

Version manager

Here’s the interesting part, because I decided to write this post due to this topic.

As a dev, there’re some cases where you need to run a project in an old version, so I decided to check for options. To my surprise, I found that Go though on that and you can install multiple Go versions by just typing something such as:

$ go get golang.org/dl/go1.10.7
$ go1.10.7 download

NOTE: Here you can find the list of available versions.

However, the second command didn’t work, but why? So, due to I’m a guy who tries to automate his setup process via dotfiles, I installed Go via homebrew, nevertheless, if you do that, you will need to update your PATH environment variable for making the second command works.

First, if you review your current installation, you will see the next path:

$ which go
/usr/local/bin/go # Output of "which go"

Then, review your workspace path:

$ go env GOPATH
/Users/jusethag/go # Output of "go env GOPATH"

If you’re getting values from the commands above, we’re good to go to the next step.

In my case, since, I’m using Z shell as my Unix shell, I needed to update my .zprofile file. However, if you’re using bash, you will need to update the .bash_profile file. Basically, with the previous values, you will need the below lines:

export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

Then, just apply your changes with $ source ~/.zprofile (run it in your terminal).

After that configuration, you will be able to run the second command. In case you want to use that version, you will need to use something like:

$ go1.10.7 version # Instead of "$ go version"

Last recommendations

Hopefully, this post can help you with some common questions that everyone could have when they are starting. So, if you want to go deeper with the macOS setup, I encourage you to review this tutorial from DigitalOcean, It’s a good one. Moreover, whether you’re learning or looking for good resources, I suggest reviewing a personal Twitter thread where I’m posting my progress with some resources that I found useful.

comments powered by Disqus