Start learning free

LESSON 57 OF 671 · STRINGS I

String Concatenation II in Go

Lesson

Concatenation means joining strings together.

In Go, use the + operator to create a new string:

message := "Hello, " + "Andy"
fmt.Println(message) // Output: Hello, Andy

You can also use += to append more text to an existing string variable:

message := "Coding is "
adjective := "worthwhile"

message += adjective
message += ", isn't it?"

fmt.Println(message) // Output: Coding is worthwhile, isn't it?

Assignment
Follow the Coding Tutorial and build the final message using +=.


STEP 1 OF 3
    Ctrl + Enter to check