Inspectopedia 2025.2 Help

Convert string literals

Reports double-quoted string literals that can be converted into raw string literals and raw string literals that can be converted to double-quoted string literals.

Example:

var s = "Hello\n \"World\""

After the quick fix is applied:

var s = `Hello "World"`

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

GoConvertStringLiterals
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Go | Code style issues

There are two notes that you should take into account while converting double-quoted strings to raw strings:

  • According to the Go language specification, the carriage return character ('\r') is discarded from the raw string values. As there is no way to show carriage return in raw strings, we discard carriage return characters when converting a double-quoted string to a raw string.

  • The backtick character ('`') cannot exist in raw string literals because there is no way to escape it. Therefore, converting double-quoted strings that contain the backtick character to raw strings is not possible and will result in a syntax error. The user can decide to undo the conversion or use some form of concatenation to preserve the backtick in a double-quoted string. For example, "`ab``" will result in `ab``, which is syntactically incorrect. The user can either undo the operation or change the resulting string to `ab` + "`".

Inspection ID: GoConvertStringLiterals

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection GoConvertStringLiterals

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

GoLand 2025.2, Qodana for Go 2025.2,

Can be installed with plugin:

Go, 252.26654.0

Last modified: 18 September 2025