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:
After the quick fix is applied:
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.
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 Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Go, 243.23131 |