# Code Style. Go

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/idea/2026.3/llms.txt).

> **TL;DR**
> Open settings by pressing `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) and navigate to `Editor | Code Style | Go`.
>
>
>
> Reformat code: `Ctrl+Alt+L` (Windows), `⌘ ⌥ L` (macOS), `⌘ ⌥ L` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ L` (macOS System Shortcuts), `Ctrl+Alt+L` (XWin), `Ctrl+Alt+L` (GNOME), `Alt+Shift+L` (KDE), `Ctrl+Alt+L` (Emacs), `Ctrl+Alt+L` (Sublime Text), `⌘ ⌥ L` (Sublime Text (macOS)), `Ctrl+Alt+Enter` (Visual Studio), `⌘ ⌥ ⏎` (Visual Studio (macOS)), `Alt+Shift+F` (NetBeans), `Ctrl+Alt+L` (Eclipse), `⌘ ⇧ F` (Eclipse (macOS))

Use this page to configure formatting options for Go files. When you change these settings, the Preview pane shows how this will affect your code.

## Tabs and Indents

Indentation widths are measured in spaces, not in tab characters. For example, an indent of 4 with a tab size of 4 uses one tab when Use tab character is selected.

| Item | Description |
| --- | --- |
|  Use tab character |    Use the `Tab` (Windows), `⇥` (macOS), `⇥` (IntelliJ IDEA Classic (macOS)), `⇥` (macOS System Shortcuts), `Tab` (XWin), `Tab` (GNOME), `Tab` (KDE), `Tab` (Emacs), `Tab` (Sublime Text), `⇥` (Sublime Text (macOS)), `Tab` (Visual Studio), `⇥` (Visual Studio (macOS)), `Tab` (NetBeans), `Tab` (Eclipse), `⇥` (Eclipse (macOS)) key for indentation. When the checkbox is cleared, IntelliJ IDEA uses spaces instead of tabs.  This checkbox is selected by default.     |
|  Smart tabs  |      * If this checkbox is selected, the indentation for nested code blocks will use tabs and spaces as needed, while alignment indentation will use only spaces.    * If this checkbox is cleared, only tabs are used. This means that a group of spaces that fits the specified tab size is automatically replaced with a tab, which may result in breaking fine alignment.     The Smart tabs checkbox is available if the Use tab character option is enabled.  This checkbox is cleared by default.     |
|  Tab size  | In this field, specify the number of spaces included in a tab. Default value: `4`. |
|  Indent  | In this field, specify the number of spaces to be inserted for each indent level. Default value: `4`.  |
|  Continuation indent  |      Specify the indentation for lines that continue from the previous line, making it clear that they are part of the same statement or block of code. Continuation indents are used when a single statement is too long to fit on one line.       Default value: `4`.    |
|  Keep indents on empty lines  | If this checkbox is selected, IntelliJ IDEA will keep indents on the empty lines as if they contained some code.     If this checkbox is cleared, IntelliJ IDEA will delete the tab characters and spaces.      This checkbox is cleared by default.    |

## Wrapping and Braces

Configure wrapping options and the usage of braces.

| Item | Description |
| --- | --- |
| Hard wrap at |     Use the Hard wrap at  field to specify a margin space required on the right side of an element. If you select the Default option, then a value of the right margin from the [global settings](settings-code-style.html#rightMargin) is used.      |
| Wrap on typing |     Use the  Wrap on typing  settings to specify how the edited text is fitted in the specified  Hard wrap at  :         * Default: in this case IntelliJ IDEA uses the Wrap on typing option that is specified in the [global settings](settings-code-style.html#wrapOnTyping).    * Yes : in this case IntelliJ IDEA uses the value specified in the Right Margin field.    * No : in this case this option is switched off and a line can exceed the value specified in the right margin.      |
| Visual guides |     Use the  Visual guides  field to specify multiple right margins. You can leave a default value or enter the number of spaces for your margin. If you want to specify several margins, enter numbers separated by comma.      |
| Function call arguments |    Select wrapping options for function call arguments. In Go, function call arguments are the values that are passed to a function when it is called.     You can select between the following options:        * Do not wrap: when this option is selected, no special wrapping style is applied, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped so that there is one element per line with proper indentation.       You can apply the previous options to opening and closing parentheses:       * New line after '(': add a new line after an opening parenthesis.    * Place ')' on new line: add a new line before a closing parenthesis.     |
| Composite literals |    Select wrapping options for composite literals. In Go, a composite literal is a compact notation for creating a value of a composite type, which includes arrays, slices, maps, and structs.     You can select between the following options:        * Do not wrap: when this option is selected, no special wrapping style is applied, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped so that there is one element per line with proper indentation.       You can apply the previous options to opening and closing parentheses:       * New line after '(': add a new line after an opening parenthesis.    * Place ')' on new line: add a new line before a closing parenthesis.     |
| Function parameters |    Select wrapping options for function parameters. In Go, function parameters are variables that are declared as part of a function signature and are used to pass data to the function when it is called. The values passed to the function as arguments are assigned to the function's parameters, allowing the function to operate on the data.     You can select between the following options:        * Do not wrap: when this option is selected, no special wrapping style is applied, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped so that there is one element per line with proper indentation.       You can apply the previous options to opening and closing parentheses:       * New line after '(': add a new line after an opening parenthesis.    * Place ')' on new line: add a new line before a closing parenthesis.     |
| Function result parameters |    Select wrapping options for function result parameters. In Go, result parameters appear after the parameter list in a function signature. They define the values that the function returns.     You can select between the following options:        * Do not wrap: when this option is selected, no special wrapping style is applied, the nested alignment and braces settings are ignored.    * Wrap if long: select this option to have lines going beyond the right margin wrapped with proper indentation.    * Wrap always: select this option to have all elements in lists wrapped so that there is one element per line with proper indentation.    * Chop down if long: select this option to have elements in lists that go beyond the right margin wrapped so that there is one element per line with proper indentation.       You can apply the previous options to opening and closing parentheses:       * New line after '(': add a new line after an opening parenthesis.    * Place ')' on new line: add a new line before a closing parenthesis.     |

## Imports

Configure code style rules for the `import` section.

| Item | Description |
| --- | --- |
| Use backquotes for imports | Replace double quotes with backquotes.     \| Enabled \| Disabled \| \| --- \| --- \| \| ![go_use_backquotes_for_imports_cleared](https://resources.jetbrains.com/help/img/idea/2026.3/go_go_use_backquotes_for_imports_set.png) \| ![Use backquotes for imports](https://resources.jetbrains.com/help/img/idea/2026.3/go_use_backquotes_for_imports_cleared.png) \|    |
| Add parentheses for a single import | Add parentheses around a single `import` declaration. |
| Remove redundant import aliases | Remove an import alias when it matches the package qualifier and no other qualifier is required. For example, the `logrus` alias is removed from the following import entry:    ```GO                     import ( 	logrus "github.com/sirupsen/logrus" ) ```    |
| Sorting type | Select what style to use for sorting the import statements. You can select between the following options:       * gofmt: sorts import paths alphabetically within each existing import group. ![gofmt Sorting type](https://resources.jetbrains.com/help/img/idea/2026.3/go_gofmt_sorting_type.png)    * goimports: sorts import paths alphabetically. It puts paths that contain a period into a separate group and puts paths that start with `appengine` into another group. The options below can add groups for Go SDK and local packages. ![goimports Sorting type](https://resources.jetbrains.com/help/img/idea/2026.3/go_goimports_sorting_type.png)    * none: does not sort `import` statements. ![none Sorting type](https://resources.jetbrains.com/help/img/idea/2026.3/go_none_sorting_type.png)    |
| Move all imports to a single declaration | Combine non-C imports into one `import` declaration and sort them.     \| Disabled \| Enabled \| \| --- \| --- \| \| ![Move all imports in a single declaration](https://resources.jetbrains.com/help/img/idea/2026.3/go_move_all_imports_in_a_single_declaration.png) \| ![Move all imports in a single declaration](https://resources.jetbrains.com/help/img/idea/2026.3/go_move_all_imports_in_a_single_declaration_disabled.png) \|    |
| Group packages from Go SDK | Put imports from Go SDK packages in a separate group. For example, imports from `fmt` and `errors` are grouped together.     \| Disabled \| Enabled \| \| --- \| --- \| \| ![Group packages from Go SDK enabled](https://resources.jetbrains.com/help/img/idea/2026.3/go_group_packages_from_go_sdk_off.png) \| ![Group packages from Go SDK disabled](https://resources.jetbrains.com/help/img/idea/2026.3/go_group_packages_from_go_sdk_on.png) \|                      The formatter keeps imports in separate groups when blank lines separate them. To put Go SDK imports from all groups together, select Move all packages to a single group.     ![Move all                         packages to a single group](https://resources.jetbrains.com/help/img/idea/2026.3/go_move_all_packages_to_a_single_group.png)  |
| Group | Select Group to create a separate group for local imports. Then select one of the following options:       * Current project packages: create a separate group for packages that belong to the current project.    * Imports starting with: create a separate group for imports whose paths start with one of the comma-separated prefixes. ![Imports starting with](https://resources.jetbrains.com/help/img/idea/2026.3/go_imports_starting_with.png)    |

## Other

| Item | Description |
| --- | --- |
| Add a leading space to comments | Add a space after `//` in line comments.     \| Disabled \| Enabled \| \| --- \| --- \| \| ![Add a leading space to comments](https://resources.jetbrains.com/help/img/idea/2026.3/go_add_a_leading_space_to_comments_off.png) \| ![Add a leading space to comments](https://resources.jetbrains.com/help/img/idea/2026.3/go_add_a_leading_space_to_comments_on.png) \|     To exclude comments that start with a specific prefix, click the Add icon (![the Add icon](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg)), type the prefix, and click OK.     ![exclude comments that start with a certain prefixes](https://resources.jetbrains.com/help/img/idea/2026.3/go_exclude_comments_that_start_with_a_certain_prefixes.png)  |
| Column width for Fill paragraph | Set the maximum line width that the Fill Paragraph action uses in Go comments. The action uses a smaller width when indentation and the editor right margin leave less space. The default is 80 characters.     \| Before \| After \| \| --- \| --- \| \| ![Column width for Fill paragraph](https://resources.jetbrains.com/help/img/idea/2026.3/go_column_width_for_fill_paragraph_before.png) \| ![Column width for Fill paragraph](https://resources.jetbrains.com/help/img/idea/2026.3/go_column_width_for_fill_paragraph_after.png) \|    |
| On Reformat Code action | Run `gofmt` after you invoke Reformat Code. This option requires a configured Go SDK that contains `gofmt`. The option is enabled by default. |

## See also

### Procedures

[Code style schemes](configuring-code-style.html)

