In Go, you can concatenate two strings using the +
operator or the fmt.Sprintf
function. Here's an example:
main.go200 chars14 lines
In the above example, both str1 + str2
and fmt.Sprintf
concatenate str1
and str2
into a new string, which is then assigned to str3
and str4
, respectively. The %s
verb in fmt.Sprintf
is a format specifier that tells the function to substitute the value of str1
and str2
as strings.
The output of the above code will be:
main.go28 chars3 lines
gistlibby LogSnag