英文:
How do I run a EXE Go executable from within IntelliJ IDEA?
问题
我有一个Go程序,我在Windows机器上的IntelliJ IDEA上进行开发。由于程序的结构有点不寻常(这里不想详细说明,因为这不是重点),所以我首先必须使用以下命令编译程序:
go build -o cli.exe
然后我可以直接在命令提示符中运行cli.exe
。
但是,我该如何配置IntelliJ IDEA中的运行配置,以便它可以运行Windows可执行文件?因为如果我尝试告诉它运行一个EXE文件作为运行配置,它会给我一个错误提示"Main file is invalid"。
我该如何解决这个问题?
英文:
I have a Go program which I'm working on in IntelliJ IDEA on a Windows machine. The program's structure is a little unconventional (don't want to go into detail here as its besides the point) because of which I first have to compile the program using the following command:
go build -o cli.exe
And then I can run cli.exe
directly in the command prompt.
But how do I configure the run configuration in IntelliJ IDEA so that it doesn't mind running a Windows executable ? Because if I try to tell it to run an EXE file as it's run configuration, it gives me error "Main file is invalid"
How do I solve this ?
答案1
得分: 1
确保在运行/调试配置窗口的文件字段中输入的是文件名(而不是文件夹名)(在IntelliJ IDEA中,转到菜单运行->编辑配置...->your_configuration)。这是我的情况。
英文:
Make sure you have a file name (not a folder name) in field File on Run/Debug Configuration window (In IntelliJ IDEA go to menu Run->Edit Configuration...->your_configuration). That was my case.
答案2
得分: 0
你可以在Windows上安装Bash插件,然后使用Bash插件创建一个运行配置,并从脚本中运行你的可执行文件。
英文:
You may be able to install the Bash plugin on Windows, then create a run configuration using the Bash plugin, and just run your executable from a script.
答案3
得分: 0
创建一个Go应用程序运行配置,然后应该就可以运行了。你可以选择运行一个文件或一个包。如果你能提供更多细节,答案会更完整。如果你对此仍有问题,请在错误跟踪器中打开一个问题,我将能够提供帮助(请遵循问题模板)。
英文:
Create a Go Application run configuration and that should work. You can choose to run either a file or a package. If you would share more details then the answer would be more complete. If you still have an issue with this, please open an issue to the bug tracker and I'll be able to help out (please follow the issue template there).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论