Shared indexes
One of the possible ways of reducing the indexing time is by using shared indexes. Unlike the regular indexes that are built locally, shared indexes are generated once and are later reused on another computer whenever they are needed.
GoLand can connect to the dedicated resource to download and build shared indexes for your project's code. Whenever GoLand needs to reindex your application, it will use the available shared indexes and will build local indexes for the rest of the project. Normally, this is faster than building local indexes for the entire application from scratch.
Make sure the plugin is installed
To be able to use shared project indexes, the Shared Project Indexes bundled plugin must be enabled in the settings:
In the Settings/Preferences dialog (Ctrl+Alt+S), select Plugins.
Switch to the Installed tab, type
Shared Project Indexes
, and make sure that the checkbox next to it is selected.Otherwise, select the checkbox to enable the plugin.
Apply the changes and close the dialog. Restart the IDE if prompted.
When you launch a project, GoLand processes local and shared indexes together at the same time. This might increase CPU usage on your computer. If you want to avoid this, enable the Wait for shared indexes option in .
Shared project indexes
Shared project indexes are built for all project sources, libraries, and SDKs. You can generate them on one computer and then apply on another computer. This is the main advantage of shared indexes over ordinary indexes.
Using shared indexes is reasonable for large projects, where indexing might take a lot of time, creating inconveniences for the teams involved. For smaller projects, we recommend other ways of reducing the indexing time.
Before you begin
To ensure index compatibility, use the same IDE version on the source and the target computer.
You can have different operating systems on the source and the target computer.
Share project indexes from the command line
In order to share project indexes, install a command line tool and prepare the IDE. By doing so, you're making sure that no caches or other internal files interfere with the information that you are going to export from your project.
When the indexes and related metadata are exported, upload them to your file storage. Other members of your team can then configure their IDEs to automatically connect to that storage and download the indexes whenever they are needed.
Prepare a file storage
Sharing indexes from the command line requires that you have a file storage that will keep the exported project indexes.
Make sure that you have a file storage ready, and all members of your team have access to this storage.
Install cdn-layout-tool
To be able to export and share project indexes, install cdn-layout-tool – a JetBrains tool for working with shared project indexes:
Download the latest version of the tool from the Space repository.
Once the .zip file is downloaded, extract its contents to a meaningful location.
Among the .zip file's content, there's a bin directory. There, you will find an OS-specific startup script that you will need later for generating metadata.
Prepare the IDE for sharing project indexes
Create a folder where you want to store your shared indexes.
For example, it can be the indexes directory in the root directory of your user (for example, /Users/jetbrains/).
Create the following directories or remove the contents from the existing ones:
ide-system
ide-config
ide-log
Copy the <IDE home>/bin/idea.properties file to the directory where you want to store your shared indexes (in our case, it is /Users/jetbrains/indexes). For more information on idea.properties, refer to Common properties.
To find the <IDE home> directory, use the following default paths.
Windows: %APPDATA%\JetBrains\<product><version> (for example, C:\Users\JohnS\AppData\Roaming\JetBrains\GoLand2022.3).
macOS: ~/Library/Application Support/JetBrains/<product><version> (for example, ~/Library/Application Support/JetBrains/GoLand2022.3).
Linux: ~/.config/JetBrains/<product><version> (for example, ~/.config/JetBrains/GoLand2022.3).
Rename idea.properties to ide.properties.
Change the following properties in the ide.properties file Point these properties to directories that you created on Step 2. Consider the following example for macOS.
idea.system.path=/Users/jetbrains/indexes/ide-system
idea.config.path=/Users/jetbrains/indexes/ide-config
idea.log.path=/Users/jetbrains/indexes/ide-log
If you don't have these properties in the file, add them at the end.
Set a temporary environment variable to specify the custom IDE properties file. To do so, run the following command:
set GOLAND_PROPERTIES=<temp>=C:\indexes\ide.propertiesexport GOLAND_PROPERTIES=<temp>=/Users/jetbrains/indexes/ide.propertiesThe following screenshot shows the configuration process on macOS.
Export project indexes
In the directory with shared indexes, ensure that the generate-output directory is empty. If there's no such directory, do not create it as this will be done automatically during the export.
Run the IDE with the following command line to export the project indexes to generate-output.
Consider the following example of the script for macOS. You can run this script in the Terminal tool window ( ) in the IDE.
goland dump-shared-index project --output=/Users/jetbrains/indexes/generate-output --tmp=/Users/jetbrains/indexes/temp --project-dir=/Users/jetbrains/git/go-metrics/ --project-id=go_metrics --commit=cf1acfcdf4751e0554ffa765d03e479ec491cad6Otherwise, consider the following approaches to run the IDE from the command line.
You can find the executable for running GoLand in the installation directory under bin. To use this executable as the command-line launcher, add it to your system
PATH
as described in Command-line interface.- Syntax
- goland.bat dump-shared-index project --output=<temp>/generate-output --tmp=<temp>/temp --project-dir=<path> --project-id=<project-name> --commit=<Git HEAD>
- Options
--output=<temp>/generate-output
Output location for the generated shared indexes in the <temp> folder.
--tmp=<temp>/temp
The temp directory used for the internal needs of the IDE.
--project-dir=<path>
The path to the project for which you want to export indexes.
--project-id=<id>
The name of the project.
--commit=<vcs revision>
The VCS revision identifier (for example, Git commit hash) representing the state of the project for which the shared index is being generated.
This is needed to lay out the shared indexes of several VCS revisions in the file storage.
This identifier is optional. If it is not specified, it will be set to
-
.--compression=<compression type>
Compress shared indexes. Possible options:
xz
,gzip
, andplain
.
By default, GoLand does not provide a command-line launcher. For information about creating a launcher script for GoLand, see Command-line interface.
- Syntax
- goland dump-shared-index project --output=<temp>/generate-output --tmp=<temp>/temp --project-dir=<path> --project-id=<project-name> --commit=<Git HEAD>
- Options
--output=<temp>/generate-output
Output location for the generated shared indexes in the <temp> folder.
--tmp=<temp>/temp
The temp directory used for the internal needs of the IDE.
--project-dir=<path>
The path to the project for which you want to export indexes.
--project-id=<id>
The name of the project.
--commit=<vcs revision>
The VCS revision identifier (for example, Git commit hash) representing the state of the project for which the shared index is being generated.
This is needed to lay out the shared indexes of several VCS revisions in the file storage.
This identifier is optional. If it is not specified, it will be set to
-
.--compression=<compression type>
Compress shared indexes. Possible options:
xz
,gzip
, andplain
.
You can find the script for running GoLand in the installation directory under bin. To use this script as the command-line launcher, add it to your system
PATH
as described in Command-line interface.- Syntax
- goland.sh dump-shared-index project --output=<temp>/generate-output --tmp=<temp>/temp --project-dir=<project> --project-id=<project-name> --commit=<Git HEAD>
- Options
--output=<temp>/generate-output
Output location for the generated shared indexes in the <temp> folder.
--tmp=<temp>/temp
The temp directory used for the internal needs of the IDE.
--project-dir=<path>
The path to the project for which you want to export indexes.
--project-id=<id>
The name of the project.
--commit=<vcs revision>
The VCS revision identifier (for example, Git commit hash) representing the state of the project for which the shared index is being generated.
This is needed to lay out the shared indexes of several VCS revisions in the file storage.
This identifier is optional. If it is not specified, it will be set to
-
.--compression=<compression type>
Compress shared indexes. Possible options:
xz
,gzip
, andplain
.
The export might take some time. When the process is finished, the following files are placed to <temp>/generate-output:
shared-index-project-<name>-<hash>.ijx.xz
shared-index-project-<name>-<hash>.metadata.json
shared-index-project-<name>-<hash>.sha256
Copy the generated files to a new folder
Create a new directory and download there all the contents of your remote file storage.
You can create the new directory inside the directory that has generate-output subdirectory. This can be any directory, for example ~/indexes/project/<project name>/<VCS hash>/share.
Copy the generated files (.ijx.xz, .metadata.json, .sha256) from generate-output to the created subdirectory (in our case, share).
Generate metadata
Generate auxiliary files used by the IDE to look up for and download shared indexes. To do so, run cdn-layout-tool with the following command line.
Consider the following example command for macOS.
/Users/jetbrains/Downloads/cdn-layout-tool--0.7.52/bin/cdn-layout-tool --indexes-dir=/Users/jetbrains/indexes/goProject/cf1acfcdf4751e0554ffa765d03e479ec491cad6/share --url=127.0.0.1This command uses the following format.
<cdn-layout-tool> --indexes-dir=<dir> --url=<file storage root URL>- Options
<cdn-layout-tool>
The path to cdn-layout-tool startup script located in bin in the tool directory.
--indexes-dir=<dir>
The directory containing all the files available in the file storage, as well as the newly generated shared indexes residing in a suitable location beneath this directory.
The tool will generate the missing files and replace existing ones if necessary. After the tool has finished running, all the contents of this directory must be uploaded to the file storage. This will set the new state of the storage.
--url=<file storage root URL>
The base URL of the file storage root directory. cdn-layout-tool will substitute the download URL in all the corresponding .json index lists.
The following screenshot shows the output of the example command.
Upload the index files to your file storage
Upload all the files from share to the file storage as is.
If there are already uploaded index files in the storage, update them.
Download indexes from the file storage
Once the project indexes are uploaded to the file storage, they can be downloaded and applied on another computer.
In the project directory, create a new file intellij.yaml and add the following code:
sharedIndex: project: - url: <feed URL>Replace <feed URL> with the URL of your file storage in the following format: <file storage root URL>/project/<project-id>.
In the Settings/Preferences dialog (Ctrl+Alt+S), select .
In the Shared Project Indexes area, select the way you want to download shared indexes from the storage.
Select Download automatically to allow GoLand to download the JDK indexes silently whenever they are needed or select Ask before download if you prefer to confirm every download manually.
Apply the changes and close the dialog.
Project indexes will be downloaded to index/shared_indexes in the IDE system directory.
Remove the downloaded shared indexes
If you don't need the project indexes anymore (for example, if the project is no longer in development), you can remove them all together. In this case, the IDE will remove the regular indexes and all the downloaded shared indexes for the project and the JDK.
From the main menu, select
.In the dialog that opens, select Clear downloaded shared indexes and click Invalidate and Restart.