GoLand
 
Get GoLand

Formatting strings

Last modified: 11 February 2024

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.

Candidates for printf-like recognition

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 AltEnter or go to the settings.