Using the rename refactoring
The Rename refactoring lets you change names of symbols, files and all the references to them throughout the code.
Renaming local variables or private methods can be done easily in-line since only the limited scope is affected. Renaming types, interfaces, or public methods could potentially impact a lot of files. In this case, preview potential changes before you refactor.
Rename the Position field
Click the
Position
field.Press Shift+F6 and start typing
JobTitle
.Press Enter.
Code snippet
Rename refactoring for database fields
If we establish a connection to a database, we can rename database fields directly from the query.
Rename the worker table
Click the
worker
table.Press Shift+F6.
In the Rename dialog, type
actor
.Click Refactor.
Code snippet
Rename refactoring for JSON
GoLand detects JSON fields in strings and renames all occurrences of the field throughout the code.
Rename the name field
Click the
name
table.Press Shift+F6. To invoke the Rename dialog, press Shift+F6 two times.
Type
firstName
.In the Refactoring Preview tool window, preview the changes and click Do Refactor.