Go

Go Practice

Learn how to write Go programs step by step, one module at a time, with each module building on the last.

Go 1.26Go 1.26
Module 1

Data & Decisions

Learn the building blocks of Go: working with numbers and text, making decisions with if, for and switch, and organising data in slices and maps.

4
About this challenge

Bill servers by the hour in whole numbers: round part-hours up, convert to int64 before multiplying so the yearly forecast never overflows, and format cents as a euro label with fmt.Sprintf.

About this challenge

Sort each uptime check into up, slow or down with a switch, find the first server down and the longest outage in a for loop, and double the retry delays up to a limit.

About this challenge

Count servers per region with a map, list the regions in sorted order with maps.Keys and slices.Sorted, and copy the online servers into a new slice without changing the one you are given.

About this challenge

Turn a day of health checks into a status page: classify each check, group the checks by region in a map, and show each region's availability in sorted order, as a percentage that never rounds up.

Module 2

Types & Errors

Learn how to design your own types in Go and handle errors: structs with methods, interfaces for things that behave alike, and errors that carry their cause.

4
About this challenge

Model a server as a struct whose pointer-receiver methods start, stop and resize it, refuse bad input with an error from its constructor, and stop a whole slice of servers in place.

About this challenge

Send one alert through email, chat and pager behind a single interface, print severities by name with a String method, and use a type assertion so that only critical alerts reach the pager.

About this challenge

Wrap a not-found error with %w, return a custom quota error or a real nil, and explain any deploy failure by looking through the wrapping with errors.Is and errors.AsType.

About this challenge

Replay a day of deploy requests: deploy each release that fits the cluster, report every failure with its step number through an interface, and count the failures by cause with errors.Is and errors.AsType.

Module 3

Generics & Iterators

Learn how to write reusable code in Go: functions and types that work for many types, and iterators that process data one item at a time.

4
About this challenge

Write generic helpers for the company's metrics: find the largest value with cmp.Ordered, clamp a value into a range, and add up and average any number type, named types like Millis included, with a Number constraint.

About this challenge

Build a generic Window[T] that keeps the last N values, drops the oldest when full, hands out a copy of its items, and finds its largest value with a function constrained by cmp.Ordered.

About this challenge

Read a log one line at a time with iterators: split text into lines with strings.Lines, keep only ERROR lines, number them from 1, and take the first N without reading further.

About this challenge

Turn a day of request logs into a metrics report: parse each line through an iterator, average the response times with a generic function, and keep the most recent ones in a generic window.

Frequently asked questions

4

What will I practice in this path?

3 modules: Data & Decisions, Types & Errors and Generics & Iterators.

How many challenges are there, and how hard are they?

12 challenges, all easy.

What does this path run on?

Challenges run on Go 1.26.

Do I need to install anything?

No. Every challenge runs in a browser-based IDE with everything already set up, and your code is graded automatically against a test suite.

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.