emahiro/b.log

Drastically Repeat Yourself !!!!

Go の unstable version で gopls を使う

以下の設定をする。

# Create an empty go.mod file, only for tracking requirements.
cd $(mktemp -d)
go mod init gopls-unstable

# Use 'go get' to add requirements and to ensure they work together.
go get -d golang.org/x/tools/gopls@master golang.org/x/tools@master

go install golang.org/x/tools/gopls

ref: https://github.com/golang/tools/blob/master/gopls/doc/advanced.md#unstable-versions

gopls-unstable dir の部分は .local/go などの任意のディレクトリでも可能。

go install ~ すると GOPATH 配下にコマンドがインストールされて path が通るので、上記手順で自動的に最新版(手元にある Unstable version )で gopls が動くようになります。