Go · Stage 6 – Reusable Code · Lesson 36 of 64

Why Functions Matter

Understand a function as one named, reusable job.

Go code

fmt.Println("Hello")
Line-by-line explanation
  1. Println is a function from fmt.
  2. The brackets call it.
  3. The string is information passed to it.
Expected output
Hello

This is the expected result.

Copying the same instructions into several places makes fixes easy to miss. A function gives that job one home.