Skip to content
KerwinKoo edited this page Dec 29, 2015 · 1 revision

go 分号 换行

s := "Starting part"
+ "Ending part"

会被自动转换为:

s := "Starting part";
+ "Ending part";

这个是错误 的,应当写成:

s := "Starting part"+
 "Ending part"

这样Go就不会在错误的地方插入分号,另外一种方式就是使用反引号(``)作为原始字符串符号:

s := `Starting part
 Ending part`

此时s也包含了换行。因为反引号中间的字符会保持不变。

[[TOC]]

Clone this wiki locally