Setup Go Development Environment with VS Code and WSL on Windows

0. Prerequisites

  • Your PC should be running a newer version of Windows 10 which supports WSL. Check WSL’s documentation for detail.
  • Currently the remote development extensions are only supported by the insiders build of VS Code. Stable builds should support them later.

1. Setup WSL

Enable WSL Feature

“Windows Features” dialog

Install a WSL Distro

Shell (Optional)

Terminal (Optional)

Terminus (with the “Hurtado“ color scheme)

2. Install Go in WSL

Install from Ubuntu Repository

sudo apt update
sudo apt install golang-go

Install a Binary Release

wget https://dl.google.com/go/go1.12.5.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.12.5.linux-amd64.tar.gz
export GOPATH="$HOME/Go" # or any directory to put your Go code
export PATH="$PATH:/usr/local/go/bin:$GOPATH/bin"

3. Configure VS Code

Install the Remote Development Extension

Enter Remote Dev Environment

Setup the Go Extension

VS Code remote development environment
An “Install on WSL” button will be shown on installed extensions

Install Go Tools

Configure the remote Go extension

{
"terminal.integrated.shell.linux": "/usr/bin/zsh",
"go.gopath": "/home/beta/Coding/Go",
"go.goroot": "/usr/local/go",
"go.formatTool": "goformat",
"go.autocompleteUnimportedPackages": true,
"[go]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}
}

3. FAQ

--

--

--

Software developer. GUI enthusiast.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

RubySwap Monthly Burn #4 February 2022

Efficient products development: how to make a good roadmap

SharpHound: Technical Details

OmniFlix Network — Community Update #35

Analysis of Algorithms

AWS Lambda Performance Series — Part#3: An Analysis on Performance of Accessing DynamoDB from a…

Imagine thing mission understand make.

How to choose a CMS for your website

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
beta

beta

Software developer. GUI enthusiast.

More from Medium

gorilla/mux 101 (rk-boot): Add prometheus middleware

Generics in Golang.

[Golang] Dealing with Errors in Golang

Test Driven Development in GO