Go development using WSL in Win 10

blov · · 925 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Was wondering if anybody here uses Windows 10 + WSL (aka Bash for Windows) for Go development?</p> <p>Although I do have a Linux laptop where I currently do most of my development, I have Win10 on my desktop &amp; would like to experiment with development on there.</p> <p>Ideally I&#39;d want go installed under WSL, however the issue I see going forward is where to keep my GOPATH and all src code. One of the main limitations(?) with WSL is that you cannot modify files from the linux subsystem within Windows, so keeping my GOPATH under the linux subsystem and editing using my text editor on Windows won&#39;t work. </p> <p>If anybody has gotten this working (or has some other reasons as to why I <em>shouldn&#39;t</em> do this, I&#39;d appreciate it :)</p> <p><a href="http://daverupert.com/2017/03/my-bash-on-windows-developer-environment/" rel="nofollow">This</a> is the post that inspired me to try in the first place.</p> <hr/>**评论:**<br/><br/>Redundancy_: <pre><p>I develop Go on Windows, and honestly haven&#39;t had much of a need for bash (it was handy for doing some quick file system interaction checks). You can cross compile anyway, but I&#39;ve found that using Docker for Windows has had very little pain involved.</p></pre>aboukirev: <pre><p>I am developing in Go on Windows and using MSYS2 for <code>bash</code> et al. Works pretty well. There is an issue with <code>git</code> from MSYS2 not working well with Windows paths as parameters when run from some applications (Visual Studio Code in particular). Solved by using <code>cygpath</code> wrapper. I am cross-compiling for Linux too and then deploying to actual Debian machine.</p> <p>WSL could be useful for CI but is too much hassle for development at this time.</p></pre>VanPepe: <pre><p>I edit on windows and run stuff via wsl</p> <p>My go path is ~/go which is a symlink to /mnt/c/Users/.....</p> <p>Only issue I have is that I can&#39;t run tests and such via a GUI in Visual Studio Code.</p> <p>I also have go installed on windows with go path set to that /mnt/c/Users/.....</p> <p>That&#39;s how Visual knows what code I have in my gopath.</p></pre>thefrontpageofme: <pre><p>This.</p> <p>Doing the same here - GOPATH points to a symlinked folder under WSL that in turn points to /mnt/c/Users/....</p></pre>brianketelsen: <pre><p><a href="https://brianketelsen.com/my-cross-platform-dev-setup-on-surface-laptop/" rel="nofollow">Here&#39;s my (long-ish) writeup on using WSL for Go development:</a></p></pre>[deleted]: <pre><p>I use GoLang in W10 and the same, I dont almost need bash, I just have some utils mapped, like ssh for example.</p></pre>lambrospetrou: <pre><p>One solution would be to have your editor in WSL too and run it using an X-Server in Windows. It&#39;s not ideal (some editors like VSCode don&#39;t work with X-server) but it works if you really want to be inside WSL most of the time.</p> <p>I tried that with Sublime Text 3 with success, but returned back to my Linux system after a week!</p> <p>My article explaining how to set this up <a href="https://www.lambrospetrou.com/articles/windows-linux-subsystem-editor-setup/" rel="nofollow">https://www.lambrospetrou.com/articles/windows-linux-subsystem-editor-setup/</a></p></pre>TurboHaskal: <pre><p>I develop entirely within WSL using plan9port&#39;s Acme and Xming. It works great for my needs.</p></pre>skankyyoda: <pre><p>I just develop Go directly on windows the the helping hand of cmder. Haven&#39;t come across any issue yet. No need to fudge around with WSL. </p></pre>vorg: <pre><p>A few weeks ago I installed WSL and <code>go1.9.1 linux/amd64</code> on a basic Windows 10 Home computer just out of interest. When I did <code>go run</code> on a simple program I got:</p> <pre><code>go build command-line-arguments: /usr/local/go/pkg/tool/linux_amd64/compile: fork/exec /usr/local/go/pkg/tool/linux_amd64/compile: invalid argument </code></pre> <p>I didn&#39;t bother looking at it any further -- just assumed WSL can&#39;t do Linux forking.</p></pre>Killing_Spark: <pre><p>One crazy way would be to use xming and your prefered text Editor from linux inside the wsl. Another would be to set your gopath to some location that is accessible to Windows (/mnt/c/whatever) </p></pre>FIuffyRabbit: <pre><p>Are you using Unix specific things? If not, just do the development with the w10 binaries. </p></pre>Hexodam: <pre><p>Visual studio code + powershell terminal on Windows</p> <p>Visual studio code + bash on Ubuntu</p> <p>No need to chase terminals, can use whatever terminal that is available </p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

925 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传