GoLand 2018.3 Help

Change signature

The Change Signature refactoring combines several different modifications that can be applied to a function, method, or a method specification. You can use this refactoring for the following purposes:

  • To change the method/function name.

  • To add new parameters and remove the existing ones.

  • To assign default values to new non-variadic parameters.

  • To reorder parameters.

When changing a method/function signature, GoLand searches for all usages of the method/function and updates all the calls, implementations, and override replacements of the method/function that can be safely modified to reflect the change. When you refactor a method specification, you will see a notification dialog where you can select to update all implementations as well.

Change a method or function signature

  1. Place a caret on a method/function name that you want to refactor.

  2. Press Ctrl+F6. Alternatively, select Refactor | Change Signature from the main menu or from the context menu.

  3. In the Change Signature dialog, make the necessary changes to the method/function signature depending on your needs:

    • Change the method/function name. To change the name, edit the text in the Name field.

    • Manage the method/function parameters. To configure the parameters, use the table and the buttons in the Parameters area:

      • To add a new parameter, click The Add button and specify the properties of the new parameter in the corresponding table row.

      • To remove a parameter, select any row and click The Remove button.

      • To reorder the parameters, use the Up (The Up icon) and Down (The down icon) icons.

      • To change the name or the default value of a parameter, make the necessary updates in the table of parameters (in the fields Name and Default value respectively).

  4. Click Refactor.

Add a return value

  1. Click the function name and press Ctrl+F6. Alternatively, select Refactor | Change Signature from the main menu or from the context menu.

  2. In the Change Signature dialog, click the Result parameters tab and click the Add icon (The Add icon).

  3. In the Type text field, specify the return value.

  4. Click Refactor.

Last modified: 6 February 2019

See Also