To extract a method from the expression at the caret or from a group of selected statements, press &shortcut:ExtractMethod; (Refactor | Extract | Method).

Extract method

GoLand tips of the day, build 2078