How to teach go programming to a beginner

Teaching Go to a beginner works best when the student writes more than you talk. Your job is to shrink the distance between an idea and a runnable program, then get out of the way while they make the ordinary mistakes. The approach below fits a friend, a colleague, or a teenager with a laptop and a free weekend.

Start with a program they will run in ten minutes

Before any explanation of packages or compilation, get go run main.go printing something on their own machine. Install the toolchain together, and let them type the file rather than watching you type it. The first success is not about code quality; it is proof that the loop from typing to output is short and safe.

Teach one concept per program

Beginners can absorb a new idea when it is the only new thing in the file. A program that prints a greeting teaches strings and functions. The next one reads a name from the command line and teaches arguments and errors. Resist the urge to introduce slices, maps, and interfaces in the same sitting, even when the example would be tidier with them.

  • Ask them to predict the output before running it.
  • When it fails, read the error message together out loud.
  • Have them change one line and explain what changed.

Let the compiler be the bad guy

Go’s compiler is unusually direct, and you can use that instead of correcting them yourself. When a variable goes unused or a return value is dropped, invite them to read what the tool said and try a fix. This keeps you in the role of coach rather than grader, and it teaches the skill they will rely on when you are not around.

Give them a project with an audience

Nothing motivates a beginner like showing a working thing to someone else. A page served on the local network, a script that renames photo files, a small tool that totals a shared spreadsheet export. Keep the scope to an evening or two, and help them publish it in a repository with a short README. The publishing step teaches version control without turning it into a lecture.

Set a rhythm and protect it

Two short sessions a week beat one long one, because forgetting is the main obstacle at this stage. End every session by writing the next step on paper, and start the next by doing it. Reviewing old code for ten minutes at the start of a session is enough revision, and it builds the habit of reading as well as writing.

What should I do when they get stuck?

Ask them to describe the problem out loud before you look at the screen. Half the time the act of explaining locates the bug, and the other half gives you a much better question to answer.

Should we pair program?

Occasionally, with clear roles: one types, one reviews, then swap. All-day pairing leaves a beginner watching instead of practising, which is the opposite of the goal.

Good teaching here is mostly restraint. Keep the programs small, let the tools deliver the corrections, and make sure something gets shown to another human every couple of weeks. The student who can start a new file alone after a month has learned more than one who can recite the spec.