package main import ( "bytes" "fmt" "strings" ) func main() { // 字符串拼接1 s1 := fmt.Sprintf("%s:%d", "127.0.0.1", 8080) fmt.Println(s1) // 字符串拼接2 s2 := strings.Join([]string{"hello", "world"}, "") fmt.Println(s2) // 字符串拼接3 s3 := bytes.Buffer{} s3.WriteString("hello") s3.WriteString("world") fmt.Println(s3.String()) // 字符串拼接4 s4 := "hello" + "world" fmt.Println(s4) }
golang 字符串拼接几种方式
阅读:3382 输入:2021-07-27 10:40:00