GoLand 2018.2 Help

Disable leading spaces in comments

After you applied the Reformat Code action (Ctrl+Alt+L), GoLand may add leading spaces before the comment text.

Before the Reformat Code action

After the Reformat Code action


// easyjson:json

In Go, comments are also used as annotations. In some libraries, spaces between comment markers and annotation instructions are not processed correctly. In the previous example, easyjson:json is an annotation.

You can disable leading spaces for annotations that start with certain prefixes.

  1. Open the Settings window (File | Settings).

  2. Click Editor | Code Style | Go.

  3. Click the Other tab.

  4. Select the Add leading space to comments checkbox.

  5. In the Except for space to comments field, click the Add icon (icons general add svg).

  6. Type the prefix name that you want to add as an exception (for example, easyjson).

  7. Click OK.

code style add leading space to comments
Last modified: 12 October 2018