How do you write multi-line strings in Go?
The following snippet will print value of string variable in multiple lines.
Example
package main
import "fmt"
func main() {
// ########## Multiline Exmaple 1 ###########
multiLine1 := `Australia is a country and continent surrounded by the Indian and Pacific oceans. Its major cities
– Sydney, Brisbane, Melbourne, Perth, Adelaide – are coastal. Its capital, Canberra, is inland. The country is
known for its Sydney Opera House, the Great Barrier Reef, a vast interior desert wilderness called the Outback,
and unique animal species like kangaroos and duck-billed platypuses.`
fmt.Println(multiLine1)
// ########## Multiline Exmaple 2 ###########
multiline2 := "Line1 \n" +
"Line2 \n" +
"Line3 \n" +
"Line4"
fmt.Print(multiline2)
}
Most Helpful This Week
How do you handle HTTP timeouts with an HTTP client in Go?
How to Convert string to float type in Go?
Web Application to generate QR code in Golang
How to change slice item value in Golang?
How append a slice to an existing slice in Golang?
Illustration of Producer Consumer Problem in Golang
Print inverted full pyramid using star
Golang panic recover example
How do you read headers in an HTTP response in Go?
Golang program for implementation of ZigZag Matrix