Skip to content

Golang - Basics & Cheatsheet

go-cheat-sheet

Introduction

Go, also known as Golang, is a programming language that was developed by Google in 2007. It is a modern language that is designed to be simple, fast, and efficient. It is widely used for building scalable web applications and network services. In this guide, we will cover the basics of Golang programming language in just 30 minutes.

Installing Golang

Before we start writing our first Go program, we need to install Golang on our system. Golang is available for all major operating systems, including Windows, macOS, and Linux. To install Golang, follow these simple steps:

  1. Go to the official Go website (https://golang.org/dl/) and download the installer for your operating system.
  2. Run the installer and follow the on-screen instructions to complete the installation.
  3. Once the installation is complete, open your terminal or command prompt and type “go version” to verify that Golang is installed correctly.

Writing Your First Go Program

To write your first Go program, open your favorite text editor and create a new file with the “.go” extension. In this file, type the following code:

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

Save the file with a name of your choice, let’s say “hello.go”. Now, open your terminal or command prompt and navigate to the directory where you saved the “hello.go” file. Type the following command to compile and run the program:

go run hello.go

You should see the following output in your terminal:

Hello, World!

Congratulations! You have just written and executed your first Go program.

Conclusion

In this guide, we covered the basics of Golang programming language in just 30 minutes. We learned how to install Golang and write our first Go program. Golang is a powerful and efficient language that is easy to learn and use. If you are interested in learning more about Golang, there are plenty of online resources available to get you started. Happy coding!

Leave a message