How to run file watcher in virtual environment in GoLand?

379 Views Asked by At

I have enabled golangci-lint file watcher in GoLand but when I save file I got error like below one:

msg="Running error: context loading failed: no go files to analyze"

After some debugging I found that this error comes when I run golangci-lint without activating my virtual env. So my question is how do I tell file watcher to run golangci-lint after activating virtual environment?

So, In summary I want this:
Before running any file watcher command, Run this command

source .my_virtual_env_folder/bin/activate

This command is basically activates virtual environment.

I am new to GoLand. I tried to do google search but no luck.

1

There are 1 best solutions below

0
On

I found a workaround.

Make a executable file, write all the commands there. We have full control on which commands do we want to run and in which order. Then in file watcher "Program", paste the absolute path of this file.

I just wrote source <name_of_the_env>/bin/activate at the top of file and then wrote my main command.

This way it activated the virtual environment and then call the command.