Start learning free

LESSON 2 OF 404 · WELCOME TO GO

Introduction to Strings in Go

Lesson

TL ; DR:

  • In Go, a string is text written inside double quotes, like "Hello world".


  • Be careful not to forget a quote. This code is missing a closing quote:

    fmt.Println("Welcome!)
    

    and would produce a syntax error.



Full lesson:

We can use text in Go to express meaningful messages.

In programming, a string is a sequence of characters: letters, numbers, spaces, and symbols.

For example, we can print strings with fmt.Println():

fmt.Println("My name is Andy")
fmt.Println("Welcome to AlgoCademy!")

The output is:

My name is Andy
Welcome to AlgoCademy!

The quotes are not printed. They only tell Go where the string starts and ends.


Assignment
Follow the Coding Tutorial and let's work with strings!


Hint
Use double quotes around the text.


STEP 1 OF 1
    Ctrl + Enter to check