GOROOT and GOPATH
Go tools expect a specific structure for your source code. This structure is defined by two environment variables: GOROOT and GOPATH. Understanding and properly configuring these variables ensures your Go projects compile and run correctly.
The GOROOT variable specifies the location of your Go SDK. Usually, GoLand sets it automatically, so you don’t need to change it unless you want to use a different Go version.
The GOPATH variable defines the workspace for your Go projects. By default, its location is $HOME/go on Unix-like systems and %USERPROFILE%\go on Windows. It serves as the root directory for installed binaries, cached modules, and checksum data.
Binaries are installed to $GOBIN by
go install(default: $GOPATH/bin).Modules are cached in $GOMODCACHE by
go get(default: $GOPATH/pkg/mod).Checksum database state is stored in $GOPATH/pkg/sumdb.
For more details, see the GOPATH section of the go command documentation.
The following video demonstrates how to change the Go SDK to a newer version in GoLand.
GOROOT
The GOROOT setting defines which Go SDK version GoLand uses for your project. You can either download a new version directly from the IDE or configure a local installation.
Configure GOROOT
Open settings (Ctrl+Alt+S) and navigate to .
Select a Go version from the list. If none is available, click Add SDK to either download a Go version or select a local Go SDK installation.

Select a local Go SDK
Ensure the selected folder includes both bin and src directories.
Open settings (Ctrl+Alt+S) and go to .
Click the Add SDK button (
), then select Local.
In the file browser, navigate to the Go SDK folder on your system.
Click Open to confirm.

Download the Go SDK
Open settings (Ctrl+Alt+S) and navigate to .
Click the Add SDK button (
) and select Download.
From the list, select the desired Go SDK version.
In the Location field, specify where to install the SDK. To browse for a location, click the Browse icon (
).
Click OK to confirm the download and installation settings.
When you click Apply or OK in the settings dialog, GoLand downloads and unpacks the selected Go SDK automatically.

Using asdf
You can use asdf to manage multiple Go versions for your projects. GoLand recognizes Go SDKs installed and managed through asdf, allowing you to switch between them directly in the IDE.
asdf is a version manager that handles multiple programming languages and utilities. It lets you define different Go versions globally or per project directory:
asdf global: sets the default Go version for the entire system.asdf local: sets the Go version for a specific project or directory.
GoLand supports both asdf local and asdf global configurations. You can also specify multiple versions, for example: asdf local golang 1.21.0 1.20.8. The IDE automatically detects the configured versions and displays them in the Go SDK list.
Select an asdf-managed Go version for the project
Open settings (Ctrl+Alt+S) and navigate to .
From the list of available SDKs, select the Go version managed by asdf. If asdf is installed and configured, the versions it provides will appear automatically.

Once the version is selected, GoLand uses the corresponding Go SDK for building, running, and testing your project. You can change the version at any time using the same settings page or by updating your .tool-versions file in the project directory.
GOPATH
The GOPATH variable defines the workspace where your Go projects, downloaded modules, and installed binaries are stored. You can configure it globally or per project and module, depending on your workflow.
In GoLand, GOPATH can be set at different scopes, allowing you to separate environments for various projects or SDK versions.
Configuring GOPATH for different scopes
You can configure GOPATH for one of the following scopes:
The IDE automatically sets the default GOPATH to $HOME/go on Unix systems and %USERPROFILE%\go on Windows. You can change it in the settings as described below.
Configure GOPATH
Open settings (Ctrl+Alt+S) and navigate to .
Select the scope you want to configure:
Global GOPATH: applies to all projects in the current installation of GoLand.
Project GOPATH: applies only to the current project.
Module GOPATH: applies to a specific module. Each module can use a different SDK or framework configuration.
Click Add (
) to add a new path.
In the file browser, select the directory you want to associate with GOPATH. The selected path will be used to store downloaded modules, binaries, and caches.

When you apply the changes, GoLand updates the Go environment automatically. New paths are reflected in the project configuration and used by Go tools for imports, builds, and dependency management.