Start learning free

LESSON 1 OF 404 · WELCOME TO GO

Printing to the Console in Go

Lesson

TL ; DR:

  • The console is a panel that displays important messages, like output and errors.


  • In Go, we use fmt.Println() to print something and move to a new line. For example:

    fmt.Println(13)
    

    prints 13 to the console.



Full lesson:

Much of the work the computer does with our code is invisible by default. If we want to see a value on the screen, we can print it to the console.


fmt.Println():

In Go, fmt.Println() prints the value we give it and then prints a newline character.

fmt.Println(1)
fmt.Println(2)
fmt.Println(3)

The output is:

1
2
3

Assignment
Follow the Coding Tutorial and let's print a value to the console!


Hint
Use fmt.Println().


STEP 1 OF 1
    Ctrl + Enter to check