AITeky Learn

AiTeky Original Interactive Learning & Practice Intermediate

Go: errors as values, deferred cleanup and the upload that said success

See how Go reports failure as a returned value that is easy to ignore, how deferred cleanup runs in reverse order and piles up inside loops, and find why an upload reported success while saving nothing.

Go has no exceptions for ordinary failures. A function that can fail returns an error as a second value, and the caller must look at it. That keeps failure visible in the code, and it also makes it easy to ignore: a program that throws the error away carries on as if nothing happened. Go's defer statement schedules cleanup for when a function ends, which is tidy, but it has two traps of its own.

This course models returned errors and deferred cleanup with small Python programs you can run in your browser. Python stands in for Go: the code is not Go, but returning an error value and running deferred calls in last-in, first-out order are the real behaviour. Check the Go documentation for exact syntax, error wrapping and defer rules. All numbers are made up.

  • Learn lessons explain one idea at a time and let you run it.
  • Industry ready lessons decide and justify, and end with interview questions.

No Go experience is assumed. Basic Python helps.

Locked. Sign up free

Learn

Understand each idea with everyday examples. No coding background needed.

  1. 01 25 min Free sample 🔒 AiTeky Pass The error you did not look at Model a function that returns a value and an error, see what happens when the caller ignores the error, and write the check that stops a failure being silent.
  2. 02 25 min 🔒 AiTeky Pass Defer runs last in, first out See that deferred calls run in reverse order when a function ends, and that a defer inside a loop holds every resource until the whole function returns.

Industry ready

Real problems from real jobs, and the questions interviewers ask about them.

  1. 03 30 min 🔒 AiTeky Pass On the job: the upload that said success An upload endpoint reported success while some files were never saved. Count the silent losses, compare four fixes by effort and risk, choose, and write the note.

We use essential cookies to run the site. With your permission we also set one anonymous ID to count unique visitors, and analytics cookies to see which pages help learners. Cookie notice

Join AiTeky Learn. It's free.

Create a free account to track your progress, save items for later and get study suggestions.

Sign up free Log in