简体   繁体   中英

run/debug go application with more then one file on the main package with gogland

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! :)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM