HiveBrain v1.2.0
Get Started
← Back to all entries
snippetgoCritical

How do you write multiline strings in Go?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
multilineyouhowwritestrings

Problem

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

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


If not, what is the preferred way of writing strings spanning multiple lines?

Solution

According to the language specification, you can use a raw string literal, where the string is delimited by backticks instead of double quotes.

`line 1
line 2
line 3`

Code Snippets

`line 1
line 2
line 3`

Context

Stack Overflow Q#7933460, score: 1491

Revisions (0)

No revisions yet.