如何在GoLand中设置调试? [英] How to set up debugging in GoLand?

查看:1280
本文介绍了如何在GoLand中设置调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试 GoLand ,听说调试器据说很棒,但是我可以找不到任何说明如何设置它的文档(GoLand处于预览阶段,因此并不奇怪).我的用例:我正在编写一个REST API,我使用curl向其发送请求.有人可以逐步告诉我如何开始使用调试器吗?

I am trying out GoLand and hear that the debugger is supposedly awesome, but I can’t find any documentation explaining how to set it up (GoLand is in preview stage, so that’s not really surprising). My use case: I am writing a REST API to which I send requests using curl. Could someone please tell me, step by step, how to get started with the debugger ?

(从注释中移出)当我单击运行/调试"(或运行/运行")时,将显示一个窗口,要求我编辑配置.我可以选择几种配置,我尝试选择转到应用程序",但是调试"按钮从不显示为灰色,我无法使其变为可单击状态.我是GoLand的新手,可能遗漏了一些明显的东西,但找不到任何缺少的设置.

[edit 1] (moved from comment) When I click Run/Debug (or Run/Run), a window is displayed, asking me to edit configurations. I am given a choice of several kinds of configurations, I try to choose "Go application" but the Debug button never is grayed and I can't get it to become clickable. I am very new to GoLand, I may be missing something obvious, but I can’t find whatever settings are missing.

[edit 2]事实证明,我的工作空间不符合Go规范:我的代码不在名为src的目录中.既然如此,我可以单击运行/调试",GoLand似乎做对了,除了它不会在断点处停止或表现得像调试器一样,我的代码才可以运行.

[edit 2] It turns out that my workspace did not conform to the Go specifications : my code was not in a directory named src. Now that it is the case, I can click Run/Debug and GoLand seems to be doing the right thing, except it doesn’t stop at breakpoints or otherwise behave like a debugger, my code just runs.

[edit 3]再次尝试,并且可以正常工作.有点.我什至不知道为什么现在可以使用,即使以前没有,而且我也没有做任何更改.现在,断点在某些行而不是其他行工作.否则调试器会在断点处停止,但我会永远等待变量列表被加载.嗯,毕竟它是一个预览...

[edit 3] Tried again, and it works. Sort of. I have no idea why it works now, even though it didn’t previously and I didn’t change anything. Now breakpoints work at some lines, and not at others. Or the debugger stops at the breakpoint, but I wait forever for the list of variables to be loaded. Well, it is a preview, after all...

[edit 4]今天才通知我,有一个新版本的GoLand.我升级了,调试对我来说现在很好.

[edit 4] I was notified just today that a new version of GoLand was available. I upgraded, and debugging is working well for me now.

推荐答案

如果您的代码不在src内部,Gogland将不会启用调试操作(尽管可以运行).对此没有任何警告,因此解决这个问题可能真的很痛苦.

Gogland will not enable the debug action (although run is available) if your code does not reside inside src. There is no warning about this, so it might be really a pain to solve this.

此外,根据项目的结构,调试仍然可能无法进行.在这种情况下,可能有助于删除所有运行的配置并创建一个新的配置.关于此行为,有一个错误报告.

Additionally, depending on your project’s structure it might be possible, that debugging is still not working. In that case, it might help to remove all run configurations and create a new one. There’s is a bug report about this behavior.

PS:尽管OP在问题的编辑中提到了第一部分,但它认为在答案中值得一提.

PS: Although the OP mentions the first part in an edit of the question, but it think it’s worth mentioning in an answer.

这篇关于如何在GoLand中设置调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆