Start learning free

LESSON 5 OF 404 · WELCOME TO GO

Syntax Errors in Go

Lesson

TL ; DR:

  • Syntax errors are mistakes in the grammar of Go code.


  • Forgetting a quote in a string causes a syntax error:

    fmt.Println("Welcome!)
    
  • Forgetting a closing parenthesis also causes a syntax error:

    fmt.Println("Let's code!"
    



Full lesson:

Go expects code to follow exact syntax rules. If the code breaks those rules, the program cannot compile.

For example, this string is invalid because the quotes do not match:

greeting := "Hey there!

This function call is invalid because the closing parenthesis is missing:

fmt.Println("My name is Andy"

Assignment
Follow the Coding Tutorial and fix the syntax errors.


Hint
Check quotes and parentheses.


STEP 1 OF 1
    Ctrl + Enter to check