ubuntu - 如何在 Win 10 中使用 WSL Ubuntu Bash 开发 Go App

标签 ubuntu go windows-subsystem-for-linux goland

我有一个带有 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/

相关文章:

ubuntu - 通过 bower 卡住安装 Polymer

node.js - 需要建议 : Latest version of Node. js 与使用 Synaptic 包管理器?

go - 如何实现fasthttp框架

mysql - 允许 CleartextPasswords=1 到 DSN

windows - 是否可以在没有 Microsoft Store 的情况下在 Windows 10 WSL 中安装 Ubuntu?

node.js - Nginx 下载索引而不是提供它

regex - 获取中间数字的正则表达式

bash - Windows 上的 GCC - Windows 上 Ubuntu 上的 Bash (WSL)、CygWin、MinGW

swift repl 在 linux 的 windows 子系统中不起作用

linux - 如何从 systemd 配置文件中的函数输出设置 ExecStart?