How do you write multi-line strings in Golang

Last updated on Jun 26, 2021 by Suraj Sharma



In this tutorial, you will learn how you can write multi-line strings in Golang

The easiest way to write a multiline strings in Golang is to use backtick(``) instead of double quote("")


Example

package main

import "fmt"

func main () {
    str := `string1
string2
string3`

    fmt.Print(str)
}


Related Solutions


Rate this post


Suraj Sharma is the founder of Future Gen AI Services. He holds a B.Tech degree in Computer Science & Engineering from NIT Rourkela.