go · level 1 · unit 1 · lesson 4
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
An is a clue, not a disaster.
An error is Go saying it got stuck. Everyone gets them, even experts. Go checks your whole program before running it, so if anything is wrong, not even the first line runs.
A means Go cannot read your code, like a sentence with a word missing. Often a quote mark, comma or bracket has gone astray. newline in string means a string never got its closing quote.
means Go met a name it does not know. Go is , so Fmt with a capital F is a stranger to it. Go is tidy too: import a toolbox you never use, and it refuses to run.
In main.go:5:2, the 5 is the line and the 2 is how far along it, so start your search there.
guess first
One capital letter. What happens?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
package main
import "fmt"
func main() {
fmt.Println("Ready?")
Fmt.Println("Go!")
}
your turn
Your turn. Close everything you open.
Type your superpower in place of the blank. Then finish the line so the quote and the bracket are both closed, and press run.
output
press run to see what happens
fix it
Breakfast is broken. Can you fix it?
output
press run to see what happens
- Read the error message. Which line does it point to?
- It is a syntax error on line 5. Count the quote marks on that line.
- A string needs a quote at both ends. Add " before Come, then press run.
nailed it
you turned errors into clues. :D
- Errors are clues. Read the message and its line number.
- A syntax error often means a missing quote, comma or bracket.
- Go is case-sensitive:
fmtworks,Fmtdoes not.
new words in your collection
- error
- syntax error
- undefined
- case-sensitive
This lesson isn’t saved. A free account remembers every lesson you finish.