What is Google Go?

Peter Viss
4 min readJul 25, 2019

--

After I graduate from Flatiron I want to be able to learn new programming languages. So, I set a goal for myself to try to learn 5 programming languages a year. However, I did not know where to start. I know I want to get into learning a more compiled language, but I did not think I was ready to dive into Java, C++, or C# just yet. Then someone told me about Google Go and how it is syntactically nicer than most other compiled languages. This blog is mainly about what Google Go is as a language. So, what is Go anyways?

“Go is a compiled, concurrent, garbage-collected, statically typed language developed at Google.” — Rob Pike, one of the creators of Go

If you do not know what all of this means, that is okay because I will explain it for you.

Compiled Languages: A compiled language means that you are writing code, it gets translated all at once into what the computer understands, then given to the computer as a block of code. Google made Go a compiled language because they generally run faster with more data.

Concurrent: When Google says concurrent, it means that Go can run different code simultaneously. Go is actually well recognized for its concurrency because it scales better than C# or C++.

Garbage-Collected: Garbage Collection is the process in which programs try to free up memory space that is no longer used by objects, and such. Evidently, most languages use Garbage Collection differently. Go is able to bring flexibility on how you use Garbage Collecting as well as making it syntactically take up less space.

Statically Typed: A statically typed language means your code is checked before translating it to the machine. If there is an error the code would not run. Whereas dynamically typed languages would run and throw an error as it is trying to run the code.

After learning all of this I thought, “this is exactly what I want to learn as a start to diving into compiled languages.” But how do you start using Go? Then began the slightly confusing process of downloading the program. So I am going to show you a straight-forward way of doing so.

First you need to install the package. Here is the link to be able to do so. https://golang.org/dl/?source=post_page---------------------------

After you install your package and put Go into your computer, you need to be able to make a new folder in your directory. I put my folder as Go in my documents directory. This folder is where you will be keeping your code. When the Go documentation says to build a $GO ROOT, do not do it! Your GO ROOT is already set up when you install it. Doing so completely messed me up in the setting process. It took me to the directory where all of the Go source code that I installed in my computer. After setting up the program I decided to see if I can print “Hello, World” in my console.

First step was to map to my Go folder in my documents directory. Then I created a “src” folder within my Go folder. Then I created a “hello” folder that was going to house my “hello” file.

When I made the folders, I opened VS Code and wrote out what the code to say “Hello, world” in my console.

If you’re confused, don’t worry I will explain. The “package main” up at the top is the actual package you are creating with the code “Hello, world”. Then you are importing a Go package call “fmt”, which stands for format. When you write the function “main”, it should print out “Hello, world” in the console. But it doesn’t! You have to type in “build go” in the console for it to compile first, then it’ll print out in the console.

After printing a simple “Hello, world.”, I decided to see if I could do more.

Here I am importing the package “math/rand” and implementing it into the function below. Here is what it prints out in the console:

Even though this is reasonably simple code, I am excited to learn more in the future as time goes by. This only marks the beginning of my journey on learning new languages and adding more tools to my tool belt.

--

--