How to set the version of gopls to install with vscode Go extension? – Go

by
Ali Hasan
algorithm gopls visual-studio-code

Quick Fix: Install the required version of gopls manually and disable the check for updates in the vscode-go extension settings to prevent automatic updates.

The Problem:

In Visual Studio Code, how do you specify the version of gopls to be installed with the Go extension?

The Solutions:

\n

Solution 1: Manual Installation and Disabling Update Checks

\n

At present, there’s no built-in option in the `vscode-go` extension to set a specific version of gopls. To resolve this:

  1. Manually install a compatible version of gopls. For instance, if you’re using Go 1.16, you can install version v0.12.4 with the following command:

    “`
    go install golang.org/x/tools/[email protected]
    “`

  2. Disable automatic update checks for gopls in the `vscode-go` extension. This will prevent it from automatically updating gopls to a newer version that may not be compatible with your Go version:
    • Launch Visual Studio Code.
    • Press Ctrl + , (comma) to open the Settings editor.
    • Search for "go.toolsManagement.checkForUpdates".
    • Set the "go.toolsManagement.checkForUpdates" setting to "off".

By performing these steps, you can manually install a specific version of gopls and prevent automatic updates, ensuring compatibility with your Go version.

Solution 2: Set gopls version via vscode.

If you want to rollback to a specific version of any vscode extension, you can go to the extension page and click the dropdown to find Install another version. Refer to the provided image below.

[Image of Extension Go in extension page]

Q&A

Is there an option to manually set version for gopls in vscode?

No, vscode-go blindly installs latest gopls version

How can I downgrade to gopls v0.12.4 in vscode?

Manually install v0.12.4 and disable check for updates

Is it possible to rollback to specific version of vscode extension?

Yes, go to the extension page and select Install another version

Video Explanation:

The following video, titled "”VScode", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

”…