3

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.

  • What is a virtual environment? – s0xzwasd Jun 04 '22 at 21:03
  • In my organization, we use "source /bin/activate" to activate a virtual environement. Basically it contains environment variables and other dependancies – Roshan Kumar Jun 05 '22 at 03:54
  • There is no setting to configure actions before running a file watcher. I suppose you can move golangci-lint binary to a virtual environment and specify this path in GoLand, but I'm not sure of how exactly VE works in your case. – s0xzwasd Jun 07 '22 at 21:04

1 Answers1

1

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.