字符串赋值后就不能修改
var str string = "abcd"
str[0] = 'f' //这里就有能修改str内容
字符串的两种表示形式
var str2 = "abc\ncba"
fmt.Println(str2)
var str3 string = `
package main
import "fmt"
import "time"
import "unsafe"
func main(){
//go语言类型转换 type_name(expression)
var sum int = 17
var count int = 20
var mean float32
mean = float32(sum)/float32(count)
fmt.Println(mean)
}
`
fmt.Println(str3)
字符串拼接方式
str4 := "hello " + "world!"
str4 += " haha!"
fmt.Println(str4)
当一行字符串太长时,可以将+号保留在上一行
str4 += "hello " + "world " + "hello " + "world " +
"hello " + "world " + "hello " + "world " +
"hello"
fmt.Println(str4)