GoLang IDEs (GogLand Issues)

polaris · · 544 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I am just starting up in Go and decided to make a simple project to implement some popular sorting algorithms to see how well I understand the language basics. Turns out I don&#39;t understand them very well and I need a debugger! So naturally I turn to JetBrains and download their newest Gogland. </p> <p>The problem I have now run into is that it refuses to acknowledge that I have a package of files and won&#39;t let me build/run my program in the debugger or at all. Are there any IDEs you would reccommend that is in a more stable place? Or perhaps you know why Gogland is having this issue?</p> <hr/>**评论:**<br/><br/>feddasch: <pre><blockquote> <p>Are there any IDEs you would reccommend that is in a more stable place?</p> </blockquote> <p><a href="https://code.visualstudio.com/" rel="nofollow">Visual Studio Code</a> + <code>lukehoban.Go</code> extension (<a href="https://marketplace.visualstudio.com/items?itemName=lukehoban.Go" rel="nofollow">Marketplace</a>)</p></pre>whizack: <pre><p>Agreed, I&#39;ve used intellij, gogland, and atom for quite some time, but vscode has worked best for me so far.</p></pre>Zy14rk: <pre><p>Second this. VS Code is great with Go. Integrates very well with the go toolset as well. All one need do is install the Go extension by lukehoban - and the rest you&#39;ll get promted to install afterwards. Up and running in less than ten hassle free minutes :)</p></pre>fridolinKarlAdalin: <pre><p>What exactly ist the Problem with GogLand? Is there an error message? Have you set the go path for the project?</p></pre>kataclysm1337: <pre><p>I believe I have set the path, but maybe I am not doing that properly. The error I get is when I try to create a run configuration for Go Application. I then change the Run Kind to Paackage. I set the Working directory to my GoglandProjects/Project folder, made an Environment variable for GOPATH that goes to this directory, set Module to my Project, and have attempted to give this project folder path as the Package path. Gogland then gives me the error near the bottom &#34;Cannot find package /home/homedir/GoglandProjects/Project&#34;</p></pre>fridolinKarlAdalin: <pre><p>The problem seems to be that your GOPATH has the wrong directory structure. You should check out <a href="https://github.com/golang/go/wiki/GOPATH" rel="nofollow">this</a> GOPATH documentation. In short, inside your GOPATH you need three subdirectories: src, bin and pkg. Your source code belongs in <em>src</em>. Inside here you should create a directory for your source control, for example <em>github.com</em>. In this folder create a new foder with you <em>username</em>. And last but not least a new directory for your <em>package</em>. In the end your structure should look like this example: <strong>GOPATH/src/github.com/kataclysm1337/my-package</strong>. The path after <em>src</em> describes your import path for the package, so you would import it with <strong>import &#34;github.com/kataclysm1337/my-package&#34;</strong>. I believe the problem is, that GogLand cannot find a <em>src</em> folder inside your GOPATH. </p></pre>kataclysm1337: <pre><p>I have added this src folder and added my files to it. I am still getting the same error message though.</p></pre>kataclysm1337: <pre><p>nevermind I think I finally got it!</p></pre>fridolinKarlAdalin: <pre><p>What was the problem?</p></pre>kataclysm1337: <pre><p>What you said was the problem I had accidentally miss spelled something while trying to use your solution.</p></pre>PacNinja: <pre><p>Ping <a href="/u/dlsniper" rel="nofollow">/u/dlsniper</a> for Gogland issues.</p> <blockquote> <p>Are there any IDEs you would reccommend that is in a more stable place?</p> </blockquote> <p>Try VS Code with vs-go plugin. They also have debugging support in the works.</p> <p>Links:</p> <ul> <li><a href="https://code.visualstudio.com/" rel="nofollow">https://code.visualstudio.com/</a></li> <li><a href="https://github.com/Microsoft/vscode-go" rel="nofollow">https://github.com/Microsoft/vscode-go</a></li> <li><a href="https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code" rel="nofollow">https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code</a></li> </ul></pre>BlobWatanabe: <pre><p>Atom with the go-plus package, which is actually a collection of packages that turn Atom into a powerful Go IDE.</p></pre>kataclysm1337: <pre><p>Would this include a debugger?</p></pre>joncalhoun: <pre><p><a href="https://github.com/lloiser/go-debug" rel="nofollow">go-debug</a> is the most common debugger in atom and uses <a href="https://github.com/derekparker/delve" rel="nofollow">delve</a> behind the scenes to power the UI.</p></pre>sondeckis: <pre><p>I want to add a question: I can not make it work without adding project gopath. <a href="https://pasteboard.co/8T6J1pan2.png" rel="nofollow">https://pasteboard.co/8T6J1pan2.png</a> Setting this folder is mandatory? If yes then why it is not set by default (when creating new project)</p></pre>dlsniper: <pre><p>You need to follow the Go Workspace layout for your GOPATH <a href="https://golang.org/doc/code.html#Workspaces" rel="nofollow">https://golang.org/doc/code.html#Workspaces</a> Go projects need to be in such a Go Workspace (or GOPATH) in order for them to work, there&#39;s just no way around it.</p> <p>What you are showing in the picture seems to be a correct Go Workspace. In this case you can let the IDE create the project in C:\WorkPersonal\chat\src\github.com\sondeckins\chat and set the GOPATH to C:\WorkPersonal\chat (as you have in the picture). This will allow you to have a nicer view of the project. Hope it helps.</p> <p>Normally the GOPATH is set only once, in the environment, the IDE can infer that automatically for all projects, but in your case the GOPATH doesn&#39;t seem to be in the environment thus the IDE can&#39;t pick it up automatically.</p></pre>dlsniper: <pre><p>I&#39;ve seen the issue and that it has been sorted out and notified the developers as well about this. Thanks for the ping <a href="/u/PacNinja" rel="nofollow">/u/PacNinja</a>.</p></pre>

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

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