What is the difference between backticks (``) & double quotes (“”) in golang?

前端 未结 4 1396
我寻月下人不归
我寻月下人不归 2021-02-01 00:16

What is the difference between backticks (``) & double quotes (\"\") in golang?

4条回答
  •  旧巷少年郎
    2021-02-01 01:01

    In quotes "" you need to escape new lines, tabs and other characters that do not need to be escaped in backticks ``. If you put a line break in a backtick string, it is interpreted as a '\n' character, see https://golang.org/ref/spec#String_literals

    Thus, if you say \n in a backtick string, it will be interpreted as the literal backslash and character n.

提交回复
热议问题