英文:
How to run file watcher in virtual environment in GoLand?
问题
我在GoLand中启用了golangci-lint文件监视器,但是当我保存文件时,会出现以下错误:
msg="Running error: context loading failed: no go files to analyze"
经过一些调试,我发现当我在没有激活虚拟环境的情况下运行golangci-lint时会出现这个错误。
所以我的问题是,我如何告诉文件监视器在激活虚拟环境后运行golangci-lint?
所以,总结一下,我想要的是:
在运行任何文件监视器命令之前,运行以下命令:
source .my_virtual_env_folder/bin/activate
这个命令基本上是激活虚拟环境。
我是GoLand的新手。我尝试进行了谷歌搜索,但没有找到解决办法。
英文:
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
得分: 1
我找到了一个解决方法。
创建一个可执行文件,在其中编写所有的命令。我们可以完全控制要运行的命令以及它们的顺序。然后在文件监视器的"Program"中,粘贴该文件的绝对路径。
我只是在文件的顶部写了source <name_of_the_env>/bin/activate
,然后写下了我的主要命令。
这样可以激活虚拟环境,然后调用命令。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论