February 17, 2022 · 5 min read
Learning Go
As developers, we have a burden of choice when it comes to learning new tech. There are so many wonderful things to build, and so many ways to build them. This conundrum can leave one in a state of limbo, but every once in a while, you find something which is utterly exciting. For me, that thing is Go.
Burden of choice
As developers, we have a burden of choice when it comes to learning new tech. There are so many wonderful things to build, and so many ways to build them. This conundrum can leave one in a state of limbo, but every once in a while, you find something which is utterly exciting. For me, that thing is Go.
A few months ago, I was looking at a roadmap to becoming a Devops engineer out of curiosity, and this roadmap suggested Go as the preferred language for Devops Engineers. Then I read about companies like Heroku using Go to build their CLI app, and a little while later I learned about how Go is used as a backend for web development. Go’s versatility peaked my interest, and shortly thereafter I began to experiment with it.
Most of my experiments related to learning programming languages begin by checking out Codecademy to see if they offer a free course. Codecademy has exactly one Go course, and it’s all you need to get a sense of how to write basic Go code: variables, logic, functions, etc. I personally follow the Codecademy courses until I get a feel for the basic syntax, and then I move on to more hands-on projects. After I felt comfortable with Go’s syntax, I jumped into some of the Go tutorials. The first tutorial is about installing Go, followed by the classic “Hello, World!” example.
Installing Go on your local machine will probably be your first challenge, but one of the incredible things about Go is it’s versatility when it comes to operating systems and hardware. For instance, I recently installed Go on my Raspberry Pi 4 and it works as well as it does on my Mac. I won’t go into details about Go’s installation, but I would suggest downloading Go from their website and installing it manually to get a better feel of how Go works in your file system. Once you’ve installed Go, you’re ready to say “Hello, World!”
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
fmt.Println("Hello, Reader!")
}
Building a CLI “Todo” app with Go and Cobra
One of the resources the Go website has for information about building a CLI app is a wonderful slide show by Steve Francia and Ashley McNamara from OSCON 2017. A slideshow can seem like an unconventional way to build an app in this age of Youtube tutorials, but it works really well! I spent a weekend following Ashley and Steve’s wonderful slides and learned more about setting up a Go project with Cobra (a framework for CLI apps), creating flags for commands, and writing more Go functions. Once I finished the slides, I continued to experiment with the code and improved the search functionality of my app. While I mostly followed along with the slides, it was a great experience for me to gain more comfort in the Go environment, which has helped me to feel more confident writing my own Go code. I plan on using Cobra in the future for more projects and would love to create a login process for a website with the CLI app (similar to Heroku’s).
Learning Web Development with Jon Calhoun
For anyone who has looked into learning Go, they have probably come across Jon Calhoun’s website Gophercises, which is also listed on the Go site as an online resource. Gophercises and another course Algorithms with Go are a series of videos which introduce you to practical coding challenges in Go. One of Jon’s greatest strengths is his ability to produce practical content which goes deeper than many other available tutorials and courses. In addition to Jon’s free courses, there are also paid courses which have free previews.
As a web developer, I was naturally attracted to Jon’s course on web development with Go. I was hesitant to commit to a longer course for a larger amount of money than I would usually pay, but after going through the free preview, I knew I had to do it. The price of the course is $249, which might seem like a lot of money, but if you use the content to its fullest then it is worth it. I’m close to being done with the course, and I couldn’t be happier with what I learned. Jon not only shows you how to build a web application in Go, he shows you his methodology for building and debugging quality applications. He also makes great use of the Go documentation (which is awesome in its own right) and explains his decision making.
Kubernetes and Google Cloud Platform
My interest for Go was peaked in a roadmap for Devops engineers, so let’s get into deploying apps with Kubernetes and GCP. GCP has a great learning program with hands-on courses to teach you how to properly deploy a website using a Kubernetes (written in Go) cluster and its CLI kubectl (also written in Go). I have done a few of the courses on GCP’s learning platform, and I think it’s yet another testament to Go’s versatility to be able to build a website, write commands in a CLI, and manage your app’s infrastructure with tech that has been written in Go. Of course, this must have been the point of Google developing a programming language, but it is an amazing thing to experience as a software engineer. To see this feat of human ingenuity for yourself, watch Kelsey Hightower build and deploy an app written in Go on GCP.
My hope for the near future is to deploy the website I’ve written with Jon to GCP in a Kubernetes cluster, but there’s still plenty of learning to do, as there always is. For now, the capabilities and possibilities of Go are nothing less than pure awesomeness, and I’m having a lot of fun learning more about Go’s packages.