Setup Windows 10 With WSL for Golang Development

Danny Aguswahyudi
Aug 3, 2020 · 5 min read
Image for post
Image for post

Windows 10 now supports Windows Subsystem for Linux and it let you run GNU/Linux environment on top of the Windows system.

I am going to walk through the minimum setup for Golang development with Windows 10 + WSL.

The setups are:

  • Installing WSL
  • Installing Ubuntu for the WSL
  • Installing Docker
  • Installing VS Code
  • Installing Golang in WSL

Before you start, check your windows version with Windows Key + R and then type winver.

Image for post
Image for post
Windows version

In case you have Windows version older than version 2004 you can’t install WSL 2, but you still able to install WSL 1. You need to update your Windows 10 to version 2004 Build 19041 in order to install WSL 2. To update it, you can update from your Windows setting or use the Windows update assistant.

In case you saw this following screen from update assistant, that is fine and you can keep installing WSL and using Linux environment on your Windows.

Update Assistant failed to update Windows to ver 2004
Update Assistant failed to update Windows to ver 2004
Windows update to version 2004 issues

In my case, it is not an issue with WSL 1 for my development enviroment. For full comparison between WSL and WSL 2 you can check it here.

Installing WSL

To install WSL, you need to enabling “Windows Subsystem for Linux” optional feature. There are two ways to doing it.

First way, open PowerShell as Administrator and run:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Second way, goes to Turn Windows features on or off setting and check Virtual Machine Platform and Windows subsystem for Linux

Image for post
Image for post
Turn Windows features on or off

Installing Ubuntu for WSL

Installing Ubuntu is pretty simple in Windows 10. You can go to Windows Store and search ubuntu then click “Get”, it will install it on your WSL directly.

Once the installation is done, try to press Windows Key and type “Ubuntu”, then open the Ubuntu application listed there, you should be redirected to a linux terminal and your linux system already up and running.

Install Golang in WSL

In this example, we are going to install Go 1.14.4 version, in case you want to install the newer version, the steps should be identical you just need to replace the download link from Go official site. Open your WSL terminal and run these commands:

# Download the Golang source into ~/Download folder
wget -P ~/Download
# Extract the source code
sudo tar -C /usr/local/ -xzf ~/Download/go1.14.4.linux-amd64.tar.gz

To verify your installation you can type go version and it should show the go version installed on WSL.

Installing VS Code

For working with VS Code, you should install it on your Windows side, not in the WSL. Go to VS Code site and download the Windows installer. Then open the downloaded .exe file and finish the installation.

When prompted to Select Additional Tasks during installation, be sure to check the Add to PATH option so you can easily open a folder in WSL by typing code command on the working directory.

After the installation is finish, install the “Remote Development Extension Pack” to your VS Code. You can install it from here, or you can search it on the VS Code extension market place.

Image for post
Image for post
Extension Marketplace

After restarting you VS Code, you should see WSL on the bottom left corner of your VS Code. And now you are able to use your VS Code normally.

Image for post
Image for post

Installing Docker in WSL

This step might not required if you are not using docker for your development. In case you need it you can run these following command from your WSL. (in my case, I am installing Ubuntu 20.04 in my WSL)

# download .deb package for docker                       
wget -P ~/Download

wget -P ~/Download
wget -P ~/Download
# installing docker-cli and docker-ce
sudo dpkg -i ~/Downloads/docker-ce-cli_19.03.12\~3-0\~ubuntu-focal_amd64.deb
sudo dpkg -i ~/Downloads/containerd.io_1.2.13-2_amd64.deb sudo dpkg -i ~/Downloads/docker-ce_19.03.12\~3-0\~ubuntu-focal_amd64.deb

Try verify your installation with docker info, in case you found the output something like this one, try to use sudo.

Debug Mode: false
ERROR: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/info: dial unix /var/run/docker.sock: connect: permission denied
errors pretty printing info

If you want to access docker without sudo you can run this following command:

sudo usermod -aG docker $USER

Afterwards, close the terminal or logout your profile to take effect. That command is going to add your linux user into docker user group.

Further Setup

AutoHotkey (Key Mapper)

AutoHotkey will help you to remap your keyboard buttons for better experience with your development. Let say you are using vim and you want to swap your CapsLock into extra Esc button.

Config for Swap CapsLock into extra Esc button:

;Remap hotkeys                       

PowerToys (App Launcher)

PowerToys is an app launcher that might help you productivity. This app launcher works like “Spotlight Search” in the MacOS.


  1. Update Assistant for update Windows 10 to version 2004:
  2. Install WSL and update to WSL 2:
  3. Using VS Code for development in WSL
  4. WSL documentation

The Startup

Medium's largest active publication, followed by +755K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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