Formatting strings
GoLand provides a feature that identifies Printf
-like functions and applies corresponding coding assistance to them (for example, inspections, quick-fixes, spellchecking, highlighting, code folding, and so on).
A function is automatically recognized as Printf
-like. The criteria for a function to be a candidate for Printf
-like recognition are:
It is a function or method.
Its name ends with
f
(for example,Printf
,Sprintf
,Foof
).It contains at least two arguments.
The second-to-last argument is a string.
The last argument is variadic and of the empty interface type (
interface{}
).
On the following screenshot, Printf
-like functions are highlighted in green color.
You can exclude the function from the list of Printf
-like functions if it was detected as formatting automatically. To exclude the function, use intention actions by pressing Alt+Enter or go to the settings.
Exclude formatting functions in the settings
Press Control+Alt+S to open the IDE settings and then select
.Click Add ().
Start typing the name of the function or method that you want to exclude.
Select a function or a method from the drop-down list.
Press Enter.
Exclude formatting functions in the editor
In the editor, click the function and press Alt+Enter, and select Exclude string formatting function.
To edit functions and methods that were excluded from the list of formatting functions, open settings by pressing Control+Alt+S and navigate to
.