我有一个带有 WSL Ubuntu 18.04.1 LTS 的 Windows 10,由于兼容性问题,我无法在我的笔记本电脑上安装 Linux。
我看到的问题是在哪里保存我的 GOPATH(Golang 工作区)和所有 src 代码。 WSL 的主要限制之一是您无法在 Windows 中修改来自 linux 子系统的文件,因此将我的 GOPATH 保留在 linux 子系统下并在 Windows 上使用 Goland 或 VS Code 进行编辑将不起作用。
最佳答案
I keep the GOPATH in Windows, e.g. D:\go, and then that's accessible via /mnt/d/go under WSL. I use two Go versions, one installed on Windows and one on WSL, and each environment uses their own version.
在我的 Alienware 中实现的解决方法:
- Install WSL Ubuntu (go1.12.4 linux/amd64), JetBrains GoLand 2019.1 x64
- Configure the GOPATH in Ubuntu:
export GOPATH=/mnt/d/dev/golang_ws
- Configure the Project Goland in the folder: "D:\dev\golang_ws"
- Build and Test the Golang application in WSL Ubuntu, using Ubuntu Bash.
or
- IntelliJ IDEA uses cmd.exe in the terminal view by default. To replace it with the Ubuntu bash, open up the IntelliJ IDEA settings menu located under “File” > Settings > Tools > Terminal >
Start directory : D:/dev/golang_ws
Shell Path : C:\Windows\System32\bash.exe
Tab Name: Local
关于ubuntu - 如何在 Win 10 中使用 WSL Ubuntu Bash 开发 Go App,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55719071/