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

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

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

4条回答
  •  星月不相逢
    2021-02-01 00:56

    Backtick strings are analogs of multiline raw string in Python or Scala: r""" text """ or in JavaScript:

    String.raw`Hi\u000A!`
    

    They can:

    1. Span multiple lines.

    2. Ignore special characters.

    They are useful:

    1. For putting big text inside.

    2. For regular expressions when you have lots of backslashes.

    3. For struct tags to put double quotes in.

提交回复
热议问题