For a better understanding of this example, we always recommend you to learn the basic topics of Golang programming listed below:
Concatenation is the process of joining one string to the end of the another string. We can concatenate strings by using the ‘+’ operator. Foe example
String 1 is learnetutorials
String 2 is elearning
String 1 + string 2 = learnetutorials elearning.
Here we are showing how to concatenate two strings in the Go language. Here variables str1,str2 are holding the string to be concatenated. And variable str for holding the result string. Finally, the strings are concatenated using str3:= str1 + str2 and print the result. Given below are the steps which are used in the Go program.
STEP 1: Import the package fmt
STEP 2: Start function main()
STEP 3: Declare the string variable str1,str2 for concatenate
STEP 4: Consider variable str3 for holding the result string
STEP 5: The concatenation is done as str3 := str1 + str2
STEP 6: Finally print the variable str using fmt.Println()
package main
import (
"fmt"
)
func main() {
str1 := "Go"
str2 := "Programming"
str3 := str1 + str2
fmt.Println(str3)
}
Go Programming