GoLand 2025.1 Help

Formatting strings

GoLand provides a feature that identifies Printf-like functions and applies corresponding coding assistance. This includes inspections, quick-fixes, spellchecking, highlighting, code folding, and similar actions.

A function is automatically recognized as Printf-like if it meets the following criteria:

  • It is a function or method.

  • Its name ends with f (for example, Printf, Sprintf, Foof).

  • It has at least two parameters.

  • The second-to-last parameter is a string.

  • The last parameter is variadic and of the empty interface type (interface{}).

In the following screenshot, Printf-like functions are highlighted in green.

Candidates for printf-like recognition

If a function is incorrectly recognized as a formatting function, you can exclude it from the list. You can do this by using intention actions (Alt+Enter) or by configuring the settings.

Exclude formatting functions in the settings

  1. Press Ctrl+Alt+S to open settings and then select Go | Formatting functions.

  2. Click Add (the Add button).

  3. Start typing the name of the function or method that you want to exclude.

  4. Select a function or method from the drop-down list.

  5. Press Enter.

    Adding formatting functions in settings

Exclude formatting functions in the editor

  • In the editor, click the function, press Alt+Enter, and select Exclude string formatting function.

    To review or edit excluded functions and methods, open the settings:

    open settings by pressing Ctrl+Alt+S and navigate to Go | Formatting strings.

    Candidates for printf-like recognition
Last modified: 04 April 2025