Learning Golang from scratch

Nuno Bispo
Aug 25, 2020 · 3 min read

In this article, the first of a tutorial series, I’ll document my journey of learning Golang and show you how you can learn also.

About Golang

From the official website description:

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

What does that mean? Well, to start Go is a compiled language instead of an interpreted language like for instance Python.

Being a compiled language means that the source code gets compiled to machine code, making it execution faster. Despite being a compiled language it has a garbage collector and run-time reflection, typical functionalities of an interpreted language.

From the official website:

It’s a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.

Installing Golang

To install Golang, just download the appropriate version for your operating system from https://golang.org/dl/

For this tutorial, I’ve downloaded the MacOS version and installed it following the wizard.

After installing, we can see if it was installed successfully by opening the Terminal and execute the command:

go version

It will generate the following output:

go version

Creating the first application

Navigate to your favourite directory in the Terminal and create a new file called ‘hello.go’:

nano hello.go

And input the following code snippet, to save do CTRL+X and answer Y then ENTER:

package main

import "fmt"

func main() {
fmt.Printf("hello, world\n")
}

The file will look like the following:

nano hello.go

Running the application

Before running the application we need to compile, since Golang is a compiled language, which we do with the following command in the Terminal:

go build hello.go

go build hello.go

After the application is compiled, we can run it with the following command in the Terminal:

./hello

It will generate the following output:

./hello

We just ran our first Golang application!!!

Next steps

We have installed and run our first Golang application, on the next article we will learn how to use a IDE to program more complex applications.

You can check out my GitHub at https://github.com/nunombispo

Or check my website at https://bispo-mobile.net

For low cost Nextcloud hosting, check out: https://cloudhomelab.com (50% discount with promo code 50OFF)

Until the next article…

Cloud Home Lab

Your Lab in the Cloud

Nuno Bispo

Written by

Outsystems Professional Web Developer for over 10 years and also as a DevOps engineer. Trying to share my knowledge and experience of all things IT.

Cloud Home Lab

Your Lab in the Cloud

Nuno Bispo

Written by

Outsystems Professional Web Developer for over 10 years and also as a DevOps engineer. Trying to share my knowledge and experience of all things IT.

Cloud Home Lab

Your Lab in the Cloud

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store