Welcome To Golang By Example

Write multiline string in Go (Golang)

A backquote (`) can be used to write a multiline string in Golang. Note that a string encoded in backquotes is a raw literal string and doesn’t honor any kind of escaping. Thus \n, \t are treated as a string literal when using back quotes

Working Code:

package main

import "fmt"

func main() {
    multiline := `This is 
a multiline 
string`

    fmt.Println(multiline)
}

Output

This is 
a multiline 
string