Getting Started with Go (Golang) for Backend Development in Visual Studio Code

Prasetyo Putra Pratama
Google Developer Indonesia
2 min readOct 4, 2023
Photo by Chinmay B on Unsplash

Introduction:
Go, often referred to as Golang, is a powerful programming language designed with simplicity and efficiency in mind. It has gained popularity among developers, particularly in backend development due to its robust standard library and performance. In this article, we’ll take you through the basics of Go and show you how to set up a development environment in Visual Studio Code.

Installing Go:
Before you start coding in Go, you’ll need to install it on your machine. Follow these steps to install Go:

1. Visit the official Go download page at https://golang.org/dl/.
2. Choose the appropriate installer for your operating system (Windows, macOS, or Linux).
3. Download the installer and run it.
4. Follow the installation prompts to complete the setup.

Once Go is installed, you can verify its installation by opening a terminal or command prompt and running the following command:

go version

You should see the installed Go version displayed.

Setting Up Visual Studio Code:
Visual Studio Code (VS Code) is a popular code editor that works well with Go. If you haven’t already installed it, you can download it from https://code.visualstudio.com/.

To make your development experience with Go smoother in VS Code, consider installing the Go extension by Microsoft. It provides features like code completion, debugging, and more. You can install it from the VS Code Extensions marketplace.

Creating Your First Go Project:
Now that you have Go and VS Code set up, it’s time to create your first Go project:

1. Open VS Code.
2. Create a new folder for your project and open it in VS Code.
3. Inside the project folder, create a new Go file with a `.go` extension, e.g., `main.go`.

Writing and Compiling Your Go Code:
Let’s write a simple “Hello, World!” program in Go to get started:

package main

import "fmt"

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

To compile and run this program, follow these steps:

1. Save the `main.go` file.
2. Open a terminal within VS Code.
3. Navigate to your project folder using the `cd` command.
4. Run the following command to compile and execute your program:

go run main.go

You should see “Hello, World!” printed in the terminal.

Conclusion:
Congratulations! You’ve taken your first steps into the world of Go (Golang) for backend development. We’ve covered the basics of installation, setting up Visual Studio Code, and creating a simple Go program. From here, you can explore Go’s powerful features and start building robust backend applications. Happy coding!

--

--

Prasetyo Putra Pratama
Google Developer Indonesia

Hi, I'm a Software Engineer and blockchain enthusiast, and I love to talk about the latest developments in technology