File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
examples/gocollective/multiline-strings Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ version : " 3"
2+
3+ tasks :
4+ run :
5+ cmds :
6+ - go run main.go
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments