How do you write multiline strings in Go?

前端 未结 9 921
傲寒
傲寒 2020-12-07 07:25

Does Go have anything similar to Python\'s multiline strings:

\"\"\"line 1
line 2
line 3\"\"\"

9条回答
  •  無奈伤痛
    2020-12-07 08:01

    For me this is what I use if adding \n is not a problem.

    fmt.Sprintf("Hello World\nHow are you doing today\nHope all is well with your go\nAnd code")
    

    Else you can use the raw string

    multiline := `Hello Brothers and sisters of the Code
                  The grail needs us.
                 `
    

提交回复
热议问题