Extract an expression at the caret as a variable by pressing &shortcut:IntroduceVariable; or navigate to Refactor | Extract | Variable. Also, you can select whether you want to replace all the occurrences of the expression in other places within a function.

GoLand tips of the day, build 2078