Home  >  Article  >  Backend Development  >  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
WBOYforward
2024-02-13 12:12:081129browse

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"}
}

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!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete