DEV Community

Cover image for Go on Node, I am all about Go(Golang)
Jonathan Reeves
Jonathan Reeves

Posted on

Go on Node, I am all about Go(Golang)

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 together to develop a language that would help them solve their issue. They ended up creating Go. Go is also commonly known as Golang due to the original website used for the language in 2009 when the language became an 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 orchestration 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 weekend and when I am finished I can save that 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. 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 Kubernetes.

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 declarative configuration language 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 site 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 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 framework itself is very simple to get up and running with and supports connecting to NOSQL and SQL databases. You can view the official site for Gin.

Fiber

Fiber is a Go web framework built on top of Fasthttps, the fastest 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 with Express as your framework of choice this would be the framework I would suggest you use after learning the basics of the Go language. It has a similar structure to how you would set up a server with Express. 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 do but you will have the safety of using a compiled statically typed language similar to Java, C#, Rust etc. I prefer Go over Java for sure as I think Java can be a bit complicated at times. I have tried them all. I have been a software engineer for four years now and I have used TypeScript, JavaScript, Python, Rust, C++, C#, Java etc. Professionally I have used JavaScript/TypeScript more than the others but when I found Go something just clicked. I am loving the language and what it has to offer. If you are unhappy with the current language or languages you are using I would recommend giving Go a look. I also use Rust from time to time but I find myself going back to Go for most of my needs.

Conclusion

I know that using Go or switching to Go might not be the ideal situation for everyone and that is ok. But I wanted to bring it to your attention if you haven't heard of it or you were running into weird performance issues with your current languages, you should give Go a shot. That's all for now. Please let me know in the comments if you are interested in learning more about Go. I am also going to be working on a series of posts that will document my time going through building a web application with Go. Just Go. No framework.

Top comments (1)

Collapse
 
aburaihan profile image
Abu Raihan

Hi @redhoodjt1988 this article is pretty good. You missed to provide website link
Image description