# Inline

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

> **TL;DR**
> `Refactor | Inline`
>
>
>
> [Inline… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "Inline")

Use the Inline refactoring to reverse the extract refactoring for a method or a variable.

<a id="inline_symbol"></a>

Procedure:

1. Place the caret at the code fragment you want to inline.

2. Press [Inline… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "Inline"). Alternatively, right-click the code fragment and select the inline refactoring that you need from the `Refactor` menu.

3. In the  dialog, specify the options.

4. (Optional) Select Preview to preview changes.

5. Preview and apply changes.

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

Currently, GoLand provides the Inline Function refactoring, which is opposite to the [Extract method](https://www.jetbrains.com/help/go/extract-method.html.md) refactoring.

<a id="examples"></a>

## Examples

<a id="inline_variable"></a>

### Inline Variable

Inline Variable refactoring replaces redundant variable usage with its initializer.

| Before | After |
| --- | --- |
|     ```GO func main() { 	subj := subject{name: "world"} 	format := "hello %s" 	fmt.Printf(format, subj.name) } ```    |     ```GO func main() { 	subj := subject{name: "world"} 	fmt.Printf("hello %s", subj.name) } ```    |

### Inline Function/Method

Inline Function/Method results in placing the method's body into the body of its caller(s).

| Before | After |
| --- | --- |
|     ```GO package main  import "fmt"  func main() { 	fmt.Println(<caret>hello()) 	print(hello()) }  func hello() string { 	return "Hello World!" } ```    |    Inline all invocations and remove declaration      ```GO package main  import "fmt"  func main() { 	fmt.Println(<caret>"Hello World!") 	print("Hello World!") } ```     Inline all invocations and keep declaration      ```GO package main  import "fmt"  func main() { 	fmt.Println(<caret>"Hello World!") 	print("Hello World!") }  func hello() string { 	return "Hello World!" } ```     Inline this invocation only and keep declaration      ```GO package main  import "fmt"  func main() { 	fmt.Println(<caret>"Hello World!") 	print(hello()) }  func hello() string { 	return "Hello World!" } ```    |

## See also

### Procedures

[Code refactoring](https://www.jetbrains.com/help/go/refactoring-source-code.html.md)

