How to Write multiline strings in Go

To create or write multiline strings in Go, use the backtick (`) character while declaring or assigning value to the string.

Multiline strings are very helpful when working with large strings like SQL, HTML or XML files inside Go.

multiline_string := `select * from
emp
`

Please go through the below example to understand it further.

package main

import "fmt"

func main() {

	multiline_string := `Hello Gophers
welcom to golangtutorial.dev
`

	fmt.Printf("%s", multiline_string)
}

//OUTPUT
Hello Gophers
welcom to golangtutorial.dev

Avatar

Arunkumar Gudelli

I am One among a million Software engineers of India. I write beautiful markup.I make the Web useful.

Follow us @ twitter, facebook and linkedin For latest news and articles about Go Language

☝ ✍ Go Language Tutorial ✍☝
Get a short & sweet Go Language tutorials delivered to your inbox every couple of days. No spam ever. Unsubscribe any time.