How to concatenate strings in Go language

We can concatenate the strings using + operator in Go Language. The input string values should enclosed in the double quotes. Otherwise it will throw the error while concatenate the strings.

#1.String Concatenation in GO language

Here we are concatenating the strings of A and B variables. The Println method is used to print the result of the strings. We have saved this program as string_concat.go and executing the program using go run command as below.


#2.Join a slices of strings into single string in Go

Here we have imported the strings package to implement the Join function in Go language. Join function is used to concatenates the elements of a string into a single string. The := syntax is shorthand for declaring and initializing a variable, e.g. input and output variables in this program.


#3.Append a strings to slice and join the same in Go

Go Language provide append function to append the new elements into a slice. Here the input variable contains all the elements of a slice. Then we have used Join function to concatenate the strings.