How to create run configuration to build directory recursively?

Hello. Is there a way to create run configuration to build directory recursively? I can see 3 options there - package, directory and file. But that's it. No option to include subdirs, also putting `...` doesn't allow me to execute (no such directory.) Creating a build for directory only doesn't seem to compile subdirs. Thanks.

1
9 comments

We don't have a run configuration for that, but you can run 'go build ./...' by configuring an external tool at `File | Settings | Tools | External Tools` like shown on a screenshot.

0

Thank you, that is helpful. It would more helpful to add checkbox which would add "/..." to directory name. You could run it as a regular go command, the same as any other things you run. Do you think there are any chances to have such feature? Would it be possible to open feature request?

0

At the moment we don't have plans to add such a feature: https://youtrack.jetbrains.com/issue/GO-6460. Could you please describe your use-case in the issue, maybe we can address it by different means?

0

Among build configuration templates there is "Go build." You may choose "Run kind" as file, package or directory. I may be mistaken but current directory option is unusable because it doesn't build subdirectories as well. In other words I would like "Go build" to have an equivalent of "go build path/..." where "/..." is optional based on the checkbox. Truth to be told, I have a feeling that building everything (with "/...") is more common then building only directory - of course this is based on my experience only.

Now, because it is among run configurations it is easy for me to find and execute it (ctrl+opt+r and choose what you need) - external tool doesn't allow for this: (1) it is in different place than rest of runs (2) you have to click through menu.

Alternatively you could allow users (via new template) to execute any Go command with custom set of parameters, similarly to Rust plugin and Cargo command.

I think the most important to note here is - after definig the build, it is easy to execute because it is on the list of other builds, runs, tests, etc. It is familiar place to have it there.

0

I understand that it is convenient to specify ./... in a run configuration. My question is: why do you want to run it?

0

To make sure compilation is okay for all my packages. We're maintaining around 1.5M LOC in one repo so it's impossible for a person to know all pieces. My use case here is - I've changed some fields in a commonly used struct. Since old fields are not here anymore I can't find all usages (opt+f7) and also I can't be sure which file is wrong unless I build it all and look at compiler errors. GoLand would show red errors in open files, but unless I know all files in advance and open them, I can't be sure. As said, this struct is used in many places, so, I build all, fix few error message, build again, fix few more. Rinse and repeat until compiler is happy.

Before I've opened the ticket I've been doing it in console (opt+f12) because fortunately it can recognize file paths and enrich the output, so I can just click the path to edit. This is moderately okay but repeating subsequent builds is not super convenient (change window, up, enter.) Would be much faster to define a run config and build all with single key stroke.

I do undarstand that it might not be common pattern of work, so I may be a minority. If it's doable - fine. If it's not - I can live with it, either.

0

And besides, there is run template for "Go build" already, isn't it? So why not improve it and make it more useful for everyone? Just add option to include subdirs.

0

Thank you for detailed description, filed a feature request: https://youtrack.jetbrains.com/issue/GO-8475.

0

Please sign in to leave a comment.