Inspectopedia 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.


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

After the quick fix is applied:

var s = `Hello "World"`

Locating this inspection


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

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` + "`".


By default bundled with

GoLand 2024.1, Qodana for Go 2024.1,

Can be installed with plugin


Last modified: 18 June 2024