# Templates with multiple files

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

Some programming patterns and frameworks require a set of related files, usually with a very specific structure.    For example, you can create separate Go files: one for your application (`main.go`) and another one for tests (`main_test.go`).

In GoLand, you can create sets of related files by adding child templates to a file template. When you create a file from such a template, it will also create files from child templates.

Procedure: Create a template with multiple files

1. In the Settings dialog (`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))), select `Editor | File and Code Templates`.

2. Create the main file template.

On the Files tab, click ![the Create Template button](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg) and specify the name, file extension, and body of the template.

3. Select the new template in the list and click ![The Create Child Template File button](https://resources.jetbrains.com/help/img/idea/2026.3/app.fileTypes.addAny.svg) on the toolbar. Specify the name, file extension, and body of the child template.

> **Note:**
> All child templates share the [variables](file-template-variables.html) of the main file template.
>
>
>
>
>
> You cannot add child templates to the default file templates.

## Example: create application and test files

Procedure:

1. 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+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)) and navigate to `Editor | File and Code Templates`. .

2. On the Files tab, click the Create Template button (![the Create Template button](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg)) and specify the following:

* Name: `App and test`

* Extension: `go`

* File name: `${NAME}`

Add the following code to the template body:

```VELOCITY
package ${NAME}

func ${NAME}() {

}
```

The name of this package and function will match the name that you provide, for example: `simpleServer`.

3. Create the test file template.

Select the App and test template in the list and click the Create Child Template File button (![The Create Child Template File button](https://resources.jetbrains.com/help/img/idea/2026.3/app.fileTypes.addAny.svg)) in the toolbar. Specify the following:

* File name: `${NAME}_test`

* Extension: `go`

Add the following code to the template body:

```VELOCITY
package ${NAME}

import "testing"

func Test_${NAME}(t *testing.T) {
	tests := []struct {
		name string
	}{

	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
		})
	}
}
```

The name of this file will be a combination of the name that you provide and the `_test` postfix, for example: `simpleServer_test`.

4. Click OK to apply the changes.

5. To use the new template, right-click a directory in the Project tool window or 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), `Ctrl+N` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Alt+Insert` (VSCode), `⌃ ⏎` (VSCode (macOS)) and select the App and test template. Specify a name for the package and main function and GoLand will create both files.

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

