英文:
run/debug go application with more then one file on the main package with gogland
问题
我下载了最新的Gogland以便运行/调试Go 1.8.1应用程序。
我在最新的Intellij Ultimate EAP中遇到了同样的问题。
我的项目的main
包包含多个文件,当我尝试将其作为Go Application
运行/调试时,它会被视为Go Single File
。
这意味着当我选择主要的go文件运行应用程序时,它会抱怨在同一目录中的其他文件中缺少变量定义,这些文件也属于main
包。
在Run Configuration
中,当我选择Package
而不是File
时,我无法选择main
包。
那么我该如何正确运行/调试我的项目呢?
谢谢!
英文:
I downloaded latest Gogland in order to run/debug Go 1.8.1 applications.
I have the exact problem in Latest Intellij Ultimate EAP.
my project's main
package contains several files, when I try to run/debug it as a Go Application
, it acts as a Go Single File
.
which means that when I try to run the application while choosing the main go file, it complains about missing variables definitions from other files on that same directory that are in the main
package as well.
in the Run Configuration
when I choose Package
instead of File
, I can't choose the main
package.
so how do I run/debug my project properly ?
thanks!
答案1
得分: 2
我已经创建了以下视频[https://youtu.be/ko-wKntCLjg]来更好地演示如何实现这一点。
视频中还展示了两个选项:
- 点击链接以添加ldflags参数:这对于Windows应用程序是必需的,以便允许调试它们,有时对于CGO应用程序(或在OSX上)也是如此。这是Go语言的问题,而不是IDE或调试器的问题。
- 第二个选项是只有一个实例。我更喜欢将我的运行配置设置为这样,因为它们允许我只运行一次,并在需要时按下相同的快捷键重新启动它们。
根据您的操作系统或应用程序类型,第一个选项可能是必需的,而第二个选项则纯粹是为了满足各种用例(正如我所说,这是个人偏好)。
希望这可以帮到您。
英文:
I've created the following video https://youtu.be/ko-wKntCLjg to better demonstrate how to achieve this.
There are two options that are also shows in the video:
- the click on the link for adding the ldflags parameter: this is needed for Windows applications in order to allow them to be debugged as well as sometimes in CGO apps (or on OSX) for the same purposes. This is an issue with Go, not the IDE or the the debugger
- the second option is the one that says Single instance only. I prefer my run configurations as such since they allow me to run them a single time and press the same shortcut to restart them when needed.
Depending on your operating system or application type, the first one might be needed, while the second one is purely functional for various use-cases (and as I've said, personal preference).
Hope this helps.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论