1. 使用加操作符</h2>

首先介绍简单使用<code> </code>操作符:

<pre><code>package main import "fmt" func main() { str3 := "hello" str4 := "Golang" // Concatenating strings Using operator result := str3 "," str4 fmt.Println("Result: ", result) } </code></pre>

输出结果:

<code>Result: hello,Golang</code>

既然加操作符可以,那么<code> =</code>也能实现类似功能:

<pre><code>package main import "fmt" func main() { // Creating and initializing strings str1 := "Welcome" str2 := " to Golang" // Using = operator str1 = str2 fmt.Println("String: ", str1) } </code></pre>

输出:

<code>Result: Welcome to Golang</code>

<h2>