How to setup Golang with VSCode

ko31 profile image Ko Takagi ・2 min read

I have used Golang some years ago, but unfortunately I hadn't tried to do it in a long time and had forgotten all about it....

So I set it up from the beginning with a fresh mind.😊

The environment I used is as follows.

  • macOS Catalina 10.15.5
  • Visual Studio Code 1.46.1

Installing Go

Download and install Go from the following link.


After the installation, open a terminal and check the version using the following command.

$ go version
go version go1.15.2 darwin/amd64
Enter fullscreen mode Exit fullscreen mode

Create directory for GOPATH setting.

$ mkdir ~/go
Enter fullscreen mode Exit fullscreen mode

For GOPATH envirionment variable, add the following lines to the ~/.bash_profile.

export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH 
Enter fullscreen mode Exit fullscreen mode

Installing Visual Studio Code

Download and install VSCode from the following link.

After the installation, Launch VSCode.

Open the Extensions Marketplace (Cmd+Shift+X), search Go and install it.

Go extension

open the Command Palette (Cmd+Shift+P) and run the Go: Install/Update Tools command.

Go extensions

Install all the Go extensions listed there.

Go extensions

Start coding

Create hello.go in VSCode.

package main

import "fmt"

func main() {
    fmt.Println("Hello, world!")
Enter fullscreen mode Exit fullscreen mode

By default, auto-completion and formatting for code saving are enabled. That's great.


Open a terminal (Ctrl+`) and execute the following command.

$ go run hello.go 
Hello, world!
Enter fullscreen mode Exit fullscreen mode

Have fun!πŸ‘

Posted on by:

ko31 profile

Ko Takagi


I am freelance web engineer in Japan. Since I am studying English, I started writing articles hereπŸ˜† I want to play catch! ⚾️


Editor guide

Exactly what I needed πŸš€


Thanks! 😊


Thank you Takagi!


Thanks! πŸ‘