VSCode and Go

xuanbao · · 679 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Greetings, gophers. I&#39;m trying to setup VSCode to write Go, I already installed Go on my system and have written, ran and built gostuff. Installed VSCode and the recommended lukehoban extension but keep getting errors about &#34;command go.gopath not found&#34; and &#34;command go.tools.install not found&#34;.</p> <p>Any clues as to what I&#39;m missing?</p> <p>All tools installed to defaults, I have gopath set in my env-vars, I&#39;m running windoze10pro64bit, latest VSCode and Go.</p> <p>Any help will be deeply appreciated.</p> <hr/>**评论:**<br/><br/>luckyleprechaun98: <pre><p>Try setting <code>go.gopath</code> explicitly in user settings. It&#39;s nearly always a problem of VS Code not seeing the same environment you have at the command line. </p> <p><a href="https://github.com/Microsoft/vscode-go/wiki/GOPATH-in-the-VS-Code-Go-extension">https://github.com/Microsoft/vscode-go/wiki/GOPATH-in-the-VS-Code-Go-extension</a></p></pre>NeerCrimson: <pre><p>I&#39;m a bit out of date with windows, but I fixed this on mac by launching from the command line. It managed to get the gopaths properly then. I had issues with manually setting it (as lucky suggestioned) when I went into debug mode with delve.</p></pre>fednemo: <pre><p>That didn&#39;t do the trick, have tried a couple of different iterations with the gopath variables in vscode and gotten nowhere</p></pre>EZYCYKA: <pre><p>Try asking in the gopher slack vscode channel.</p></pre>fednemo: <pre><p>Have not had the need to use slack yet, so I´m not familiar with it, guess this time is as good as any other to give it a try :D</p></pre>SmokyQuarks: <pre><p>Can you run the &#34;go&#34; command from the command line? (meaning your PATH envvar has been updated properly) Have you set GOROOT just in case (this shouldn&#39;t be needed anymore but who knows): <a href="https://golang.org/doc/install" rel="nofollow">https://golang.org/doc/install</a></p></pre>fednemo: <pre><p>Yes I can run go from command, have done some runs and builds already. Goroot is set.</p></pre>: <pre><p>[deleted]</p></pre>fednemo: <pre><p>Yeah... No dice, still won&#39;t work</p></pre>flogic: <pre><p>If you&#39;re using the tarball under Linux, you need to make sure to use the code executable in the &#34;bin&#34; sub directory. The root one doesn&#39;t copy the environment properly. At least that was my experience.</p></pre>ohaiya: <pre><p>Is the src directory where the files are, on the same drive as Go.</p> <p>That bugged me initially.</p></pre>sethammons: <pre><p>Similar problem. I was helping a student set up VS Code on windows. She can run Go programs from her command line, but VS Code will not see the GOPATH. Setting it explicitly with <code>go.gopath</code> does not work either. Launching VS Code from the command line does nothing. Sublime has trouble too. </p> <p>I&#39;m not a Windows person so I don&#39;t know what else to do. I feel that we exhausted Google search. Her next bet is intellij or gogland or she can learn vim and try getting it set up that way. Kinda sucks.</p> <p>For the time being, I told her that she can run things like go fmt from the command line. She will be stuck without goimports, linting, autocompletion, and all the nice things. </p></pre>dz0ny: <pre><p>Does Gopath or goroot include any nonascii or space characters?</p></pre>fednemo: <pre><p>Nope, I always try to keep stuff like this nice and simple so as to not run into character coding snafus</p></pre>

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

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