Setup Visual Studio Code for Golang

Alexey Fayzullin
3 min readOct 6, 2019

It is vital for Golang developer to use powerful IDE (Integrated development environment) like VS Code or Golang. They boost your productivity by autocompletion, highlighting code, powerful debugger, automations. You focus on code, IDE will do the rest.

In this course I will use VS Code as it is free, light and fast IDE, but extremely powerful. And it is cross platform, as Go. It is professionally designed for developer and supports almost all the programming languages.

Here is what you need to do to install VS Code and setup plugin for Golang.

Installation

  1. Download VS Code from official website: https://code.visualstudio.com/

2. Run the setup file and follow instructions in installer to complete VS Code installation. Do not forget to check “Create a desktop icon” checkbox.

3. Launch VS Code

Add Go Extension

VS Code is highly customizable by extensions. To enable Golang support you need to install extension “Go”.

  1. Launch VS Code by double clicking the VS Code icon on the desktop.

2. Press Ctrl + Shift + x or click the last icon on the left vertical navigation bar. Extensions tab will be opened.

3. You will see search list above the list on the left. Type “Golang” there and select Go extension, which will appear to be first on the list and click “Install”. It will take some time to complete.

4. When it is installed you need to reload VS Code, just close the VS Code window and then start the application again.

Try VS Code in action

  1. Click “Open Folder” button or go to top menu File > Open Folder and select or create a new folder for project.

2. Then create a new file by clicking icon +, name it “main.go”

3. You will see popups appeared in right bottom corner, offering to install required Go tools. Confirm them all and wait till installation is finished. When the tools are installed you shall restart VS Code again

4. Copy and paste this piece of code into the editor. Running this program will print text “This is my first GO app!” in console.

package mainimport “fmt”func main() {
fmt.Println(“This is my first GO app!”)
}

5. If popups will appear again or you see message like the one below, just click it, confirm installation and restart VS Code again.

6. Run your program by pressing Ctrl + F5 (Run without debug)

7. That’s it. Now you are ready to code in VS Code.

--

--