Skip to content

Golang How to Write Multiline String

If you have newlines in a string you will face an error! The simple solution is using backtick (`) around your string:

myString := `I am
new string

Another way to have a multiline while having double quotes (“) is using \n in your string:

myString := "I am \na \nnew string \nwith \nnewlines"

Leave a Reply

Your email address will not be published. Required fields are marked *