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 Client server load balancing in Go?
Golang read json file into struct
Unveiling the Potential of Quantum Computing in AI: A Game Changer for Industries
Program in Go language to Find Largest Element of an Array
Program in Go language to Calculate Standard Deviation using Math package
Top 20 Most Popular Cryptocurrencies To Watch In 2024
What is an HTTP client in Go?
How to remove all line breaks from a string in Golang?
How do you handle HTTP client server alerting in Go?
Implementing Multiple Interfaces in Go Programming Language