What is Go?
Go is a statically typed programming language created by three Google engineers, Rob Pike, Robert Griesmer and Ken Thompson in 2007. They were frustrated with compile times of C++ on the project they were working for and sat down to develop a language that would help them solve their issue. This language became known as Go. Go is also commonly known as Golang due to the original website used for the language in 2009 when the language became open-source technology. The features of Go are the following:
- Built in concurrency
- Static Type System
- Garbage Collected
- Functional paradigm
There are a few others but I just wanted to give some examples to show what the language offers. You can visit the official website here. Go comes with a standard library that, like Python, is considered a batteries included approach. There is almost nothing you can’t do with the standard library. This includes building out websites. Now that’s not to say that Go doesn’t support packages or libraries as it does, but most of your development with Go will be using the built-in libraries or packages in the standard library vs trying to find the right package or library to download and use in your project.
What Type of Content Can You Use Go For?
Go is a systems level language. Very much like C/C++ or Rust. The types of applications you can build with Go are similar to those apps you can build with the other languages. But where Go really shines is the distributed system and orchestratino space, as well as networking. Below is a list of apps that are built with Go.
Docker
For those of you that aren’t aware of Docker, Docker is an operating system (or runtime) for containers. The Docker Engine is installed on each server you want to run containers on and provides a simple set of commands you can use to build, start, or stop containers. This application was built in Go. If you are a developer and you haven’t had the opportunity to use or learn about Docker, I highly recommend looking into it. To give a good example of something that you can use Docker for: I currently use Docker on my mac and Windows computers to run an image of Mongo on each computer. I can be on the go with my mac and be developing while out and about at a coffee shop or visiting family for the weeknd. When I am finished I can save the data I created to my database and push the image up to Docker Hub which is essentially GitHub for Docker images. Then once I get home I can hop on my Windows computer and pull down the image and continue using and working with the database as though I had done all the work on this machine and not on the mac while out and about. Docker is great for creating services for a microservice application as each service can essentially be it’s own Docker container and pushed up as it’s own image to the server. The website for Docker.
Kubernetes
Kubernetes is an orchestration tool that allows the ability to manage all of your Docker containers in a central location.
The official page of Kubernetes defines it like so: Kubernetes is a portable, extensible open source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.
Kubernetes is also built in Go. Now if you are unfamiliar with the two tools Kubernetes and Docker then that’s ok. They are mainly used by DevOps engineers to help manage and maintain apps created by developers. DevOps engineers use these tools to make sure that the apps they contain and orchestrate are working correctly. There is one more tool that DevOps Engineers use quite a bit recently and that is Terraform. The official site for Kubernets
Terraform
Terraform is an open-source, infrastructure-as-code software tool. It was created by Hashicorp and was also written in Go. Users define and provide data center infrastructure using a declaritive configuration langauge known as HashiCorp Configuration Language(HCL), or optionally JSON. This tool allows DevOps engineers to quickly code out the infrastructure for their applications and run the code to spin that up either on bare metal servers, cloud solutions or even virtual machines. Check out the official stie for Terraform
Gin
Gin is a framework written in Go. The framework supports writing fullstack code as well as backend APIs. I have started to use to use this framework as a replacement to Fiber which is another Go framework I will talk about in this article. Gin has features that every backend framework has, the ability to create routes and other CRUD operations easily. The framwork itself is very simple to get up and running with and supports connecting to NOSQL and SQL databases. You can view the official sit for Gin
Fiber
Fiber is a Go web framework built on top of Fasthttps, the fatest HTTP engine for Go. It’s designed to ease things up for fast development with zero memory allocation and performance in mind. For those of you coming from Node.js, or I guess more like using the Express framework with Node.js, I would recommend this framework if you are interested in learning Go. I would however suggest that if you are new to Go try using the built in net/http package to understand how Go handles writing APIs first. The official website for Fiber
Why I Switched
If you are using something like Python or JavaScript, Go is able to do everything those languages can but offers the saftey of a compiled and statically typed language similar to Java, C#, Rust etc. I prefer Go over Java as I think that the development environment needed to build APIs with say Spring or Spring Boot can be a bit hard to learn for beginners. I have tried several frameworks with langauges that I have learned or used in the past. These include Node/Express for both JavaScript and TypeScript. Django and Flask with Python. ASP.NET for C#. Spring Boot with Java/Kotlin. Professionally I use Nestjs with TypeScript but on personal projects I use Go either by itself with just the net/http package or with Fiber or Gin. This site is built with Go using the static site generator Hugo.
Conclusion
I know that using Go or switching to Go might no be the ideal situation for everyone and that is ok. I wrote this post to show that, while I started writing APIs within the JavaScript/TypeScript ecosystem, I have made the switch to Go and don’t plan on looking back. I hope this post has helped you see what Go has to offer and piques your interest enough for you to look into the language. You might make the switch to. That’s all for now.