字符串

(1)通过 “+” 连接字符串。

var xx string = "你好"  // 
s1 := "字符串"  // 短声明
s2 := "拼接"
s3 := s1 + s2
fmt.Print(s3) //s3 = "打印字符串"

(2)使用sprintf函数生成

s1 := "字符串"
s2 := "拼接"
s3 := fmt.Sprintf("%s%s", s1, s2) //s3 = "打印字符串"

// 或者这样
 res, err := db.Exec("INSERT INTO person(first_name, last_name) VALUES (?, ?)", firstName, lastName)

(3)通过join函数

//需要先导入strings包
s1 := "字符串"
s2 := "拼接"
//定义一个字符串数组包含上述的字符串
var str []string = []string{s1, s2}
//调用Join函数
s3 := strings.Join(str, "")
fmt.Print(s3)

(4)调用buffer.WriteString函数

//需要先导入bytes包
s1 := "字符串"
s2 := "拼接"
//定义Buffe