I'm a Go Software Engineer focused on microservice architectures at Chefkoch.
VS Code Go

VS Code Go extension: Don't open imports in the browser

In VS Code, clicking on a Go import will open the GoDoc of the imported package in the browser. This behavior is driven by gopls and can be disabled.

Posted on July 26, 2021

When clicking on an imported Go package in VS Code, its GoDoc at pkg.go.dev will be opened by default. This is a feature of the Go Language Server (gopls). It works fine for packages from the standard library, but will display an error on the website if it is a private package. In most cases, when clicking onto an imported package, I want to navigate into that package.

Don't open the docs in the browser

All gopls settings can be configured in the global settings.json file in VS Code. The abovementioned behavior is configurable via the importShortcut key, which is an enum with three possible values:

  • Link: Open the link in the Go documentation.
  • Definition: Go to the package definition. This is probably what you want.
  • Both": Combines Link and Definition.

Therefore, in order to only navigate to the package definition, your gopls configuration has to look like this:

    "gopls": {
        "importShortcut": "Definition"

For further navigation settings of gopls, take a look at the official reference.

New timetrace: A simple time tracking CLI