3.5. Refactoring code
You can use the gofmt formatting tool to refactor your code by applying rewrite rules.
Procedure
To refactor your code in a given path, enter:
$ gofmt -r -w <rewrite_rule> <code_path>Replace
<code_path>with the path to the code you want to refactor and<rewrite_rule>with the rule you want it to be rewritten by.To apply the changes, enter:
# gofmt -w <code_path>Replace
<code_path>with the path to the code you want to format.