We will set up Golang in Visual Studio Code and create a Golang Hello World Project using Visual Studio Code. Visual Studio Code is an integrated Development Environment used for developing Software applications.

Prerequisites

Install Dependent Plugins in VS Code for Java Development

Open your Visual Studio Code and then we will install the plugins. Click on the Extensions Tab in VS Code. Then you can search for the extensions.

VS Code Extension

Extension Name: Go

Search for go. This will list down the Go Extension from Google. Click on the Install button for the extension Installation.

install go plugin for vs code

Create Golang Project

Find your GOPATH directory.

echo $GOPATH

Note: You may have different GOPATH based on your settings

Navigate to the GOPATH directory and create the hello-world project folder

cd <path-to-GOPATH>
mdkir hello-world

Open the Go Project folder in Visual Studio Code

Open the hello-world project in VS code by clicking File => Open Folder and then navigate to the hello-world folder

open go project in VS Code

Create main.go file by clicking File ==> New File

Create main.go file in VS code for golang

Add the Below contents in the main.go file

package main

import "fmt"

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

Run the Hello World Project in Golang

Navigate to the folder where main.go file is present and then run the file using the below command

go run main.go
run golang hello world

This is the process of creating your Project in Visual Studio Code.

References

Leave a Reply

Your email address will not be published. Required fields are marked *