How to write multi-line strings in program with Go

2 Answers

0 votes
package main
 
import "fmt"
 
func main() {
   	multiLine := `Go is a statically typed, compiled programming language designed at Google 
by Robert Griesemer, Rob Pike, and Ken Thompson. Go is syntactically similar to C, 
but with memory safety, garbage collection, structural typing, and CSP-style concurrency.`

    fmt.Println(multiLine)
}

  
  
/*
run:
  
Go is a statically typed, compiled programming language designed at Google 
by Robert Griesemer, Rob Pike, and Ken Thompson. Go is syntactically similar to C, 
but with memory safety, garbage collection, structural typing, and CSP-style concurrency.

*/

 



answered Aug 9, 2020 by avibootz
0 votes
package main
 
import "fmt"
 
func main() {
  	multiLine := "Line1 \n" +
                 "Line2 \n" +
                 "Line3 \n" +
                 "Line4"

    fmt.Println(multiLine)
}

  
  
/*
run:
  
Line1 
Line2 
Line3 
Line4

*/

 



answered Aug 9, 2020 by avibootz
...