First Glance: WSL2 & GoLand on Windows 11
Tags: go, windows, goland, beginners
Published: 2021-10-06 18:07:17

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](https://www.jetbrains.com/go/nextversion/). 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](https://docs.microsoft.com/en-us/windows/wsl/install#change-the-default-linux-distribution-installed)), enter username, password and install Go SDK.

### Install Go SDK under WSL2
There are a few ways to install Go SDK:
- [Official guide](https://golang.org/doc/install) from Go team.
- Go [snap package](https://snapcraft.io/go) on Ubuntu.

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gwx6qv6hrm1zj8g8hwh6.png)

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](https://gobyexample.com/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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6wo1ycbak06psplcz24x.png)

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

### Limitations

So, there are several limitations at the moment, especially symlinks and File Watchers are not supported ([IDEA-253253](https://youtrack.jetbrains.com/issue/IDEA-253253), [WEB-38925](https://youtrack.jetbrains.com/issue/WEB-38925)) as well as External Tools ([IDEA-201045](https://youtrack.jetbrains.com/issue/IDEA-201045)) and Mozilla RR ([GITHUB-2506](https://github.com/rr-debugger/rr/issues/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](https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps) inside WSL2 and it looks really promising.