# File template variables

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

A [file template](using-file-and-code-templates.html) can contain variables, which are replaced by their values when the template is applied. A variable is a string that starts with a dollar sign `$` followed by the variable name. The variable name may optionally be enclosed in curly braces. For example: `$MyVariable` and `${MyVariable}` are different notations of the same variable.

Predefined and custom variables are available in the template body and in the filename. For example, if you type `MyFile_${MONTH_NAME_FULL}` in the File name field of your template, the resulting file will be named `MyFile_April` if you create it in April. Here, `${MONTH_NAME_FULL}` is a [predefined](#predefined_template_variables) variable. If you use a [custom](#custom_template_variables) variable instead, GoLand will prompt you to enter the variable value when you create a file based on this template.

## Predefined template variables

The following predefined variables can be used in file templates:

| Variable | Description |
| --- | --- |
| `${GO_PACKAGE_NAME_WITH_TEST_SUFFIX}` | Name of the package in which the new file is created if it's just regular file and package + '_test' suffix if the new file is a test file |
| `${GO_PACKAGE_NAME}` | Name of the package in which the new file is created |
| `${DATE}` | Current system date |
| `${DAY}` | Current day of the month |
| `${DAY_NAME_SHORT}` | First three letters of the current month name (Mon, Tue, and so on) |
| `${DAY_NAME_FULL}` | Full name of the current day (Monday, Tuesday, and so on) |
| `${DIR_PATH}` |    Path to the directory of the new file (relative to the project root)  |
| `${DS}` |  Dollar sign `$`. This variable is used to escape the dollar character, so that it is not treated as a prefix of a template variable.  |
| `${FILE_NAME}` | Name of the new file |
| `${HOUR}` | Current hour |
| `${MINUTE}` | Current minute |
| `${SECOND}` | Current second |
| `${MONTH}` | Current month |
| `${MONTH_NAME_FULL}` | Full name of the current month (January, February, and so on) |
| `${MONTH_NAME_SHORT}` | First three letters of the current month name (Jan, Feb, and so on) |
| `${NAME}` | Name of the new entity (file, type, interface, and so on) |
| `${PRODUCT_NAME}` | Name of the IDE (for example, GoLand) |
| `${PROJECT_NAME}` | Name of the current project |
| `${TIME}` | Current system time |
| `${USER}` | Login name of the current user |
| `${YEAR}` | Current year |

## Variable methods

Because GoLand uses [Velocity](https://velocity.apache.org/) as a template engine for file templates, variables in file templates can use Java String methods. For example, the following is possible:

* `${NAME.toUpperCase()}`: convert the name of the new entity (file) to upper case letters.

* `${PROJECT_NAME.length()}`: print the length of the project name.

* `${PRODUCT_NAME.substring(0,5)}`: print the first five characters of the name of the IDE you are using.

## Custom template variables

Besides predefined template variables, it is possible to specify custom variables. If necessary, you can define the values of custom variables right in the template using the `#set` directive. Write the directive before the corresponding variable is used.

For example, if you want to use your full name instead of your login name defined through the predefined variable `${USER}`, add the following construct before your custom variable:

```
#set( $MyName = "John Smith" )
Created by: $MyName
```

If the value of a variable is not defined in the template, GoLand will ask you to specify it when the template is applied.

