First Glance: WSL2 & GoLand on Windows 11

Windows 11 was just released a few days ago and GoLand introduces support for projects inside the WSL2 mount and it is available in the Early Access Program. It is a good time to get started and combine things for modern Go development step-by-step.

I…


This content originally appeared on DEV Community and was authored by Daniil Maslov

Windows 11 was just released a few days ago and GoLand introduces support for projects inside the WSL2 mount and it is available in the Early Access Program. It is a good time to get started and combine things for modern Go development step-by-step.

I will show you a small introduction to configure WSL2 and GoLand, how to install Go SDK and open projects inside WSL2 mounts. First off, we have to install WSL2 under Windows 11. There are a few steps to consider.

Configure WSL2 on Windows 11

First off, we are going to install WSL2 itself via wsl --install in PowerShell with admin rights. The operation takes a bit of time and at the end of it, you can see the successful message: The requested operation is successful. Changes will not be effective until the system is rebooted.

I would say that the process of installing WSL2 in Windows 11 is much easier than earlier. One command does all things.

After that, open Ubuntu distribution (or change to a different one using Microsoft article), enter username, password and install Go SDK.

Install Go SDK under WSL2

There are a few ways to install Go SDK:

I prefer an official guide. It is pretty well documented and easy to start. Pay attention that it requires sudo privileges for the user.

wget -c https://golang.org/dl/go1.17.1.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local

A few preparations to use it:

  • Specify export PATH=$PATH:/usr/local/go/bin under $HOME/.profile.
  • Load $PATH changes to the current shell session: source ~/.profile.

To confirm that Go is configured properly, we can execute go version and should get the following output:

go version go1.17.1 linux/amd64

We are good to go to the next section.

Project opening in GoLand

Let's create our project right from GoLand. On Welcome Screen, select New Project and specify project location under WSL2 mount. You can create directories from the pop-up by right-clicking on the root folder. Make sure that the path to the project contains \\wsl$ prefix:

\\wsl$\Ubuntu\home\s0xzwasd\Projects\Go\dev-to-example

An option to create directories in GoLand

GoLand highlights a warning and requires Go SDK in WSL. We can click on the Plus icon and choose Local, then find Go SDK (\\wsl$\Ubuntu\usr\local\go by default). Create a project and wait for Go SDK indexing.

As an example, I take Go by Example: Interfaces code snippet. Let's run it via gutter icons around main() function. After that, try to debug a bit.

GoLand runs code from WSL2 mount

We've configured all necessary environments to get developer things done. 🎉

Limitations

So, there are several limitations at the moment, especially symlinks and File Watchers are not supported (IDEA-253253, WEB-38925) as well as External Tools (IDEA-201045) and Mozilla RR (GITHUB-2506).

Conclusion

We can use WSL2 and GoLand for Go development for now. It is much easier to get started and separate personal and development environments. As a benefit of Windows 11, we can run GUI apps inside WSL2 and it looks really promising.


This content originally appeared on DEV Community and was authored by Daniil Maslov


Print Share Comment Cite Upload Translate Updates
APA

Daniil Maslov | Sciencx (2021-10-06T18:07:17+00:00) First Glance: WSL2 & GoLand on Windows 11. Retrieved from https://www.scien.cx/2021/10/06/first-glance-wsl2-goland-on-windows-11/

MLA
" » First Glance: WSL2 & GoLand on Windows 11." Daniil Maslov | Sciencx - Wednesday October 6, 2021, https://www.scien.cx/2021/10/06/first-glance-wsl2-goland-on-windows-11/
HARVARD
Daniil Maslov | Sciencx Wednesday October 6, 2021 » First Glance: WSL2 & GoLand on Windows 11., viewed ,<https://www.scien.cx/2021/10/06/first-glance-wsl2-goland-on-windows-11/>
VANCOUVER
Daniil Maslov | Sciencx - » First Glance: WSL2 & GoLand on Windows 11. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/06/first-glance-wsl2-goland-on-windows-11/
CHICAGO
" » First Glance: WSL2 & GoLand on Windows 11." Daniil Maslov | Sciencx - Accessed . https://www.scien.cx/2021/10/06/first-glance-wsl2-goland-on-windows-11/
IEEE
" » First Glance: WSL2 & GoLand on Windows 11." Daniil Maslov | Sciencx [Online]. Available: https://www.scien.cx/2021/10/06/first-glance-wsl2-goland-on-windows-11/. [Accessed: ]
rf:citation
» First Glance: WSL2 & GoLand on Windows 11 | Daniil Maslov | Sciencx | https://www.scien.cx/2021/10/06/first-glance-wsl2-goland-on-windows-11/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.