# Using the Generate action

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

Procedure: Generate a constructor

The Generate constructor action generates a function that creates values of a struct type. For more information about constructors, refer to [Constructors and
composite literals](https://golang.org/doc/effective_go.html#composite_literals) from the Effective Go manual.

1. Place the caret at your code, and press `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Alt+Insert` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Alt+Insert` (VSCode), `⌃ ⏎` (VSCode (macOS)). Alternatively, you can use intention actions `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Ctrl+.` (VSCode), `⌘ .` (VSCode (macOS)).

2. In the Generate window, select Generate constructor.

3. In the Select Fields dialog, select fields that you want to use in the constructor.

4. Click OK.

![Generate a constructor](https://resources.jetbrains.com/help/img/idea/2026.3/go_generate_constructor.png)

Procedure: Generate getter and setter

You can generate getters and setters separately or use one action to generate both methods. For more information about getters and setters, refer to [Getters](https://golang.org/doc/effective_go.html#Getters) from the Effective Go manual.

1. Click one of the `struct` fields and press `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Ctrl+.` (VSCode), `⌘ .` (VSCode (macOS)) to invoke intention actions.

2. From the menu, select Generate getter and setter.

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/go_generate_getter_and_setter.mp4)

Procedure: Implement missing methods

To implement an interface in Go, you need to implement all the methods that are listed in the interface. In GoLand, you can automatically generate templates for those methods.

With the Implement Methods action, you can specify parameter names even if they are omitted in the interface definition.

1. Place the caret at your code, and press `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Alt+Insert` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Alt+Insert` (VSCode), `⌃ ⏎` (VSCode (macOS)).

2. In the Generate window, select Implement Methods ( or press `Ctrl+I` (Windows), `⌃ I` (macOS), `⌘ I` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ I` (macOS System Shortcuts), `Ctrl+I` (XWin), `Ctrl+I` (GNOME), `Ctrl+I` (KDE), `Ctrl+I` (Emacs), `Ctrl+I` (Sublime Text), `Ctrl+I` (Sublime Text (macOS)), `Ctrl+I` (VSCode), `⌃ I` (VSCode (macOS))).

3. In the Choose Type window, select the type that you want to use. Alternatively, click Create Type to create a new type.

4. In the Choose interface to implement field, type a name of the interface that you want to implement.

5. Replace the `panic("implement me")` line with code for the method.

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/go_generate_code_implement_methods.mp4)

Procedure: Generate an empty test file

1. Place the caret at your code, and press `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Alt+Insert` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Alt+Insert` (VSCode), `⌃ ⏎` (VSCode (macOS)).

2. In the Generate window, select Empty test file.

![Generate an empty test file](https://resources.jetbrains.com/help/img/idea/2026.3/go_generate_empty_test_file.png)

> **Tip:**
> A file with the `_test.go` suffix is created.

Procedure: Generate tests for files, packages, and functions

1. Place the caret at your code, and press `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Alt+Insert` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Alt+Insert` (VSCode), `⌃ ⏎` (VSCode (macOS)).

2. In the Generate window, select Tests for file, Tests for package, or Test for function.

Procedure: Add a copyright notice

1. Press `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+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)) to open settings and then select `Editor | Copyright | Copyright Profiles`.

2. Click the Add icon ![Add icon](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg).

3. In the Create Copyright Profile dialog, type a name for a copyright profile.

4. In the Copyright text (may contain Velocity templates) field, create or modify a copyright template.

5. Click OK.

6. Place the caret at your code, and press `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Alt+Insert` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Alt+Insert` (VSCode), `⌃ ⏎` (VSCode (macOS)).

7. In the Generate window, select Copyright.

> **Tip:**
> For more information about Velocity templates, refer to the [documentation](https://velocity.apache.org) for the Apache Velocity Project.

