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
- Extension Name: Go
- Create Golang Project
- Open the Go Project folder in Visual Studio Code
- Run the Hello World Project in Golang
- References
Prerequisites
- Visual Studio Code must be installed
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.
Extension Name: Go
Search for go. This will list down the Go Extension from Google. Click on the Install button for the extension Installation.
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
Create main.go file by clicking File ==> New File
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
This is the process of creating your Project in Visual Studio Code.