GO Program to concatenate two string

For a better understanding of this example, we always recommend you to learn the basic topics of Golang programming listed below:

How to concatenate two strings

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.

How to concatenate two strings in the GO Program

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. 

ALGORITHM

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()

 

GO Source Code

                                          package main

import (
    "fmt"
)

func main() {

    str1 := "Go"
    str2 := "Programming"
    str3 := str1 + str2
    fmt.Println(str3)

}
                                      

OUTPUT

Go Programming