Home > Backend Development > Golang > LSP-gopls in Sublime Text creates go directory in $HOME instead of custom location

LSP-gopls in Sublime Text creates go directory in $HOME instead of custom location

WBOY
Release: 2024-02-13 12:12:08
forward
1150 people have browsed it

Sublime Text 中的 LSP-gopls 在 $HOME 中创建 go 目录而不是自定义位置

php editor Xinyi discovered that some users recently reported that the LSP-gopls plug-in in Sublime Text would create go folders in the $HOME directory during the installation process, instead of according to the user Custom location. This issue may cause some inconvenience to users, so we provide a solution here.

Question content

I use Sublime Text and the LSP-gopls plugin for Go development, and I have a custom GOPATH setting: $HOME/Code/ go instead of $HOME/go.

However, every time I run Sublime Text, the directory go/pkg/mod/... is created inside the $HOME directory. Normally, LSP-gopls should store these files in the directory specified by $GOPATH, but it uses the default directory.

How to solve?

I'm sure it's LSP-gopls because when I disable it, delete the directory in $HOME and restart Sublime Text, this behavior goes away. I have export GOPATH=$HOME/Code/go in .zshrc. In the plugin settings, set the custom path to gopls to "command" : ["/Users/user/Code/go/bin/gopls"].

Workaround

Turns out I needed to set $GOMODCACHE in the LSP-golsp settings.

"settings": {
  "gopls.env": {"GOMODCACHE":"/Users/user/Code/go/pkg/mod"}
}
Copy after login

The above is the detailed content of LSP-gopls in Sublime Text creates go directory in $HOME instead of custom location. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
lsp
source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template