Skip to content

Commit 4826087

Browse files
authored
Merge pull request #569 from devlights/add-gocollective-example
2 parents 9fcc380 + 35fc71a commit 4826087

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: "3"
2+
3+
tasks:
4+
run:
5+
cmds:
6+
- go run main.go
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Stackoverflow Go Collective example
2+
//
3+
// How do you write multiline strings in Go?
4+
//
5+
// URL
6+
// - https://stackoverflow.com/questions/7933460/how-do-you-write-multiline-strings-in-go
7+
//
8+
// REFERENCES
9+
// - http://golang.org/doc/go_spec.html#String_literals
10+
package main
11+
12+
import (
13+
"fmt"
14+
"strings"
15+
)
16+
17+
func main() {
18+
// python では """ """ で multiline-strings が表現できるが
19+
// Go では ` ` で同じことになる
20+
21+
var (
22+
multilineStrings = `this is 1st line.
23+
this is 2nd line.
24+
this is 3rd line.
25+
EOF`
26+
)
27+
28+
fmt.Println(multilineStrings)
29+
fmt.Printf("%v\n", strings.Split(multilineStrings, "\n"))
30+
}

0 commit comments

Comments
 (0)