GoLand 2022.2 Help

Save and revert changes

GoLand automatically saves changes that you make in your files. Saving is triggered by various events, such as compiling, running, debugging, performing version control operations, closing a file or a project, or quitting the IDE. Saving files can be also triggered by third-party plugins.

Most of the events that trigger auto-save are predefined and cannot be configured, but you can be sure that changes will not be lost and you can find all of them in local history.

Configure autosave behavior

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Appearance & Behavior | System Settings.

  2. Under Autosave, configure the following options:

    • Save files when switching to a different application or a built-in terminal: Save all modified files when you switch from GoLand to a different application.

    • Save files if the IDE is idle for N seconds: Save all modified files at regular time intervals.

  3. Apply the changes and close the dialog.

Mark files with unsaved changes

You can mark unsaved files with an asterisk (*) on the file tab:

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Editor | General | Editor Tabs.

  2. Select the Mark modified (*) checkbox.

  3. Apply the changes and close the dialog.

    After that, the tab of the file in which you have unsaved changes will be marked with an asterisk.

If you use version control integration, names of all modified files will be also marked with a dedicated color on the file tab and in the Project tool window.

Save changes manually

You can always save your changes manually:

  • Press Ctrl+S or select File | Save All from the main menu.

Trigger actions when saving changes

In GoLand, you can configure the actions that will be triggered every time your modified files are saved.

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Tools | Actions on Save.

  2. Select the checkboxes next to the actions that you want to trigger on save:

    • Reformat code: reformat your code according to your current code style settings.

      This action is enabled by default for GoLand. When triggered, the IDE runs the built-in GoLand formatter and gofmt.

    • Optimize imports: remove unused imports and organize import statements according to your current code style settings.

    • Rearrange code: reorder code elements according to your current code style settings.

    • Run code cleanup: batch-apply quick-fixes from code cleanup inspections in the current inspection profile.

    • Update copyright notice: update information in copyright notices in project files.

    • Run eslint --fix: fix the detected problems with ESlint.

      Enabling this option also enables Run eslint --fix on save.

    • File Watcher: run your configured file watchers.

    • Upload to default server: upload modified files to your default deployment server.

      Enabling this option also enables Upload changed files automatically to the default server.

  3. For some actions, you can configure the settings more precisely. To do so, hover the mouse pointer over an action and click the configuration link.

    For example, you can specify files and folders that will be formatted when the file is saved. By default, the Go file type is selected. If you want to add other files types, hover the mouse pointer over the action and click Files: Go.

  4. Apply the changes and close the dialog.

Once the necessary actions are enabled, they will be automatically triggered on every save (autosave, explicit save invoked with Ctrl+S or by selecting File | Save All) as you work with your project.

Settings/Preferences: Actions on save

Revert changes

Last modified: 21 July 2022