GUIDE · GO TECHNICAL INTERVIEWS · 26 MIN READ
Go live-coding interviews: a fair task in a shared Playground
Run a fair Go live-coding interview: a tested rate-limiter task, an encrypted shared Playground room, a rubric for reasoning and what to keep.
Edition: · Practical guide. Sources and worked examples below.

Design the task before the call
Most unfairness in live coding is built in before the call starts. A task that only its author can finish in 45 minutes, a requirement that exists only in the interviewer's head, or a setup that fails on the candidate's browser will decide the outcome more than the candidate's engineering. Fix those problems in the task itself, where they are cheap to fix.
Start from a file that compiles. It should declare the types, the constructor and the signature the candidate will fill in, so the first minutes go to thinking rather than boilerplate. Put the contract in the file as a short numbered list and give every rule a test that carries the rule's number in its name. Then add the sentence that matters most: there are no hidden tests. If you intend to ask about a case the tests do not cover, treat it as a follow-up question that can earn credit, never as a silent failure.
Make the starting tests fail for the right reason. In the example, the stub Allow returns false, so each scenario fails on its first expected true while the constructor validation test already passes. That shows the candidate exactly where to start. It also sets up a point worth discussing later: a stub that always says no would pass every test that only checks denials.
Before using the task, solve it yourself under the same time limit, then ask a colleague who has not seen it to do the same. Keep the file set well inside the Playground budgets of 32 text files, 64 KiB per file, 256 KiB in total and a 30-second execution deadline. Use only the standard library, so nobody has to prepare packages during the call, and avoid what the browser cannot do: cgo, sockets, real network calls and the race detector. Give the task a version and record it with your notes, so every candidate at one level is assessed on the same text.
The example task: a token bucket with an injected clock
A token-bucket rate limiter is a good size for a 60-minute session. A complete answer fits in under 30 lines, yet it has real invariants: capacity, refill timing, remainder handling, clock behaviour and locking. It is familiar production territory too. The documentation for golang.org/x/time/rate describes its Limiter as a token bucket of size b, initially full and refilled at rate r tokens per second. This task uses whole tokens and one token per interval, so the arithmetic is exact and nobody has to reason about floating-point rounding under pressure.
The clock is a parameter. Accepting func() time.Time lets each test move time explicitly instead of sleeping, and it gives the debugger stable values to show. This is the complete starting file the candidate sees:
package main
import (
"fmt"
"sync"
"time"
)
// Task: implement Allow for a token-bucket rate limiter.
//
// The contract. Each rule has a test in task_test.go:
// 1. A new limiter starts full: burst calls succeed at once.
// 2. One token is added every interval, never more than burst.
// 3. Partial progress toward the next token is kept between calls.
// 4. Time spent with a full bucket earns nothing.
// 5. A clock that stalls or moves backwards adds no tokens.
// 6. Allow is safe for concurrent use.
//
// There are no hidden tests. Read them, then talk through your plan.
// Limiter is a token bucket. The clock is injected so tests need no sleeps.
type Limiter struct {
every time.Duration // one token is added per interval
burst int // capacity of the bucket
tokens int // tokens available at time last
last time.Time // refills are accounted up to this time
now func() time.Time // the clock
mu sync.Mutex
}
// NewLimiter returns a full limiter that adds one token every interval
// and holds at most burst tokens. A nil clock means time.Now.
func NewLimiter(every time.Duration, burst int, now func() time.Time) (*Limiter, error) {
if every <= 0 || burst < 1 {
return nil, fmt.Errorf("ratelimit: need every > 0 and burst >= 1, got %v and %d", every, burst)
}
if now == nil {
now = time.Now
}
return &Limiter{every: every, burst: burst, tokens: burst, last: now(), now: now}, nil
}
// Allow reports whether one event may happen now. If it may, Allow
// spends one token.
func (l *Limiter) Allow() bool {
// TODO: implement the contract above.
return false
}The candidate writes Allow and may add helpers or fields; everything else is given. Each struct field has a comment, because a candidate should not spend interview time guessing what last means. A candidate who prefers a different representation, such as tracking the time at which the next token becomes due, can say so and change the fields. That choice is a good trade-off discussion in its own right, and the tests do not depend on the internal representation.


Tests that state the contract
The test file is the specification in executable form. A small manual clock replaces sleeps, and each scenario is a list of steps: move the clock, call Allow once, compare the answer. Scenario names start with the rule number, so a failure points straight back to a sentence in the starting file.
// step moves the clock by advance, then calls Allow once.
type step struct {
advance time.Duration
want bool
}
const ms = time.Millisecond
var scenarios = []struct {
name string
every time.Duration
burst int
steps []step
}{
{"rule 1: starts full, then denies", 100 * ms, 3,
[]step{{0, true}, {0, true}, {0, true}, {0, false}}},
{"rule 2: one token per interval", 100 * ms, 1,
[]step{{0, true}, {99 * ms, false}, {1 * ms, true}, {0, false}}},
{"rule 2: never more than burst", 100 * ms, 2,
[]step{{0, true}, {0, true}, {time.Hour, true}, {0, true}, {0, false}}},
{"rule 3: keeps partial progress", 100 * ms, 1,
[]step{{0, true}, {60 * ms, false}, {40 * ms, true}}},
{"rule 4: a full bucket earns nothing", 100 * ms, 1,
[]step{{50 * ms, true}, {50 * ms, false}, {50 * ms, true}}},
{"rule 5: a backwards clock adds nothing", 100 * ms, 1,
[]step{{0, true}, {-time.Second, false}, {time.Second, false}, {100 * ms, true}}},
}Every row exists to catch a specific, plausible mistake. We checked that by breaking the reference solution one way at a time. Setting the last refill time to the current time on every call, which silently drops partial progress, fails scenarios for rules 2, 3 and 4. Capping the bucket without restarting the interval fails rules 2 and 4. Removing the cap fails the burst limit, and deleting the guard for a backwards clock fails rule 5. A row that no plausible mistake can fail is decoration; remove it rather than make the candidate satisfy it. The table-driven tests guide makes the same point: a test is worth exactly what its assertions can catch.
The concurrency test starts 200 goroutines with sync.WaitGroup.Go, available since Go 1.25, against a full bucket of 50 and expects exactly 50 successes. It then advances the clock by 20 intervals, so the callers also race to refill, and expects exactly 20. With the race detector, removing the lock or moving the refill outside it makes go test -race report a data race. In the browser this test checks counts only. When we removed the lock and ran the test binary compiled for wasip1/wasm under a WASI runtime, it passed 20 runs out of 20, so a green Playground run says nothing about the locking.
In the downloadable lab, the candidate's copy of the tests sits behind a starter build constraint, so the default test run checks the reference solution and an explicit tag reproduces the candidate's starting point:
go test -tags starter . # the candidate's starting point: FAIL
go test -race -count=3 ./... # reference, follow-up tests, x/time/rate replayFor candidates: run the tests locally
If you are the candidate, the most important fact is that every build runs on your own device. The first Run in a browser downloads roughly 47 MiB of compressed Go tools and standard-library archives, verifies them and caches them when browser storage allows. Open /playground on the computer and browser you will use, a day or so before the interview, and press Run on the Hello example. Then the first compile during the call is not also a large download. If Debug reports that your browser lacks cross-origin isolation or SharedArrayBuffer support, you also learn that early. If you edited a practice draft, export it before the interview; an earlier draft makes the room link show a notice instead of joining, and the Share panel's Or join with a link field then completes the join.
During the task, read the tests before you write code. Test builds and runs every test in the project with verbose output, so each subtest name and failure message appears in Output. Begin by reading one failure aloud. The message step 0 at 0s: Allow() = false, want true says the bucket should start full. Make the smallest change that addresses it, press Test again and say what changed in the output. Check compiles without running anything, and Format applies Go's formatter only if the source has not changed in the meantime.
Running an incomplete answer to learn something is fine, and so is pausing to think in silence, as long as you say that you are doing so. If a result looks wrong, look at the current or older source label before you debug the code. Ctrl/⌘ + Enter runs the program, and Output shows elapsed time and success or failure.
Know the two browser limits the interviewer should already have planned for. A program has 30 seconds to finish, and there is no race detector in the browser. In this task, the concurrency test checks counts in the Playground; the lab runs the same test under go test -race. If you are unsure whether your locking is right, explain your reasoning rather than relying on a green run.
Use the debugger to talk through state
Debugging aloud is one of the best ways to show reasoning, because the candidate says what they expect before the tool shows what happened. In the Playground, Debug runs the program's main function, not the tests, which is why the task includes a small main.go. It replays six calls on a manual clock with a burst of two and a 100 ms interval. With a correct Allow, it prints:
t=0s allowed=true
t=0s allowed=true
t=0s allowed=false
t=60ms allowed=false
t=100ms allowed=true
t=350ms allowed=trueClick beside a line number inside Allow to set a breakpoint, then choose Debug. Execution pauses before the first executable statement, and Continue runs to the breakpoint. Step into, Step over and Step out move through project source, the call stack lists the frames, and Locals shows bounded summaries of the current frame's values. Before each step, ask the candidate for a prediction. At 60 ms, how many whole intervals have elapsed since the last accounted time, and should the remainder survive the call?
Two practical habits help. Compute intermediate values into named locals, such as elapsed and earned. A time.Duration local appears as a plain integer count of nanoseconds, which is easy to read, while a time.Time value is summarised by internal fields that are not. Also ask observers not to type while the candidate debugs. The editor is read-only during a debug session, and a collaborator's source change stops the debug snapshot.
Know the limits so you never ask for something the tool cannot do. The debugger steps project source only, not the standard library. It has no watch expressions, conditional breakpoints or variable editing, captured locals belong to the current frame, and output is not streamed while paused. Paused time does not count against the 30-second budget, and an abandoned pause expires after 30 minutes.
A reference solution, and why it looks like this
Interviewers need a reference to calibrate the rubric, not a text to compare character by character. This is the one in the lab:
func (l *Limiter) Allow() bool {
l.mu.Lock() // rule 6: one lock covers refill, check and spend
defer l.mu.Unlock()
l.refill(l.now())
if l.tokens == 0 {
return false
}
l.tokens--
return true
}
// refill adds the whole tokens earned since l.last. The caller holds l.mu.
func (l *Limiter) refill(now time.Time) {
elapsed := now.Sub(l.last)
if elapsed <= 0 {
return // rule 5: a stalled or backwards clock adds nothing
}
// earned counts whole intervals. It stays an int64 Duration until we
// know it fits below burst, so a huge gap cannot overflow tokens.
earned := elapsed / l.every
if earned >= time.Duration(l.burst-l.tokens) {
// Rules 2 and 4: cap at burst and restart the interval now, so
// time spent full earns nothing.
l.tokens, l.last = l.burst, now
return
}
l.tokens += int(earned)
l.last = l.last.Add(earned * l.every) // rule 3: keep partial progress
}One lock covers the refill, the check and the spend. Locking each field access separately would remove the data race but keep a logical race between reading the token count and spending a token; the data races versus business races guide covers exactly that gap. The refill advances last by whole intervals only, so the remainder survives. When the earned tokens would reach the cap, the bucket is filled and the interval restarts now; the same branch implements rule 4, because a full bucket needs zero tokens and any positive elapsed time reaches that cap.
The guard for non-positive elapsed time is not paranoia. The Go time documentation explains that values returned by time.Now carry a monotonic clock reading and that subtractions use it, so successive real readings do not go backwards when the wall clock is adjusted. An injected clock, however, is only a function and can return any value. An implementation that reads the clock before taking the lock can also observe a time earlier than one another goroutine has already recorded. The guard makes both cases harmless. earned stays a time.Duration until it is known to fit below the burst, which keeps an extreme gap from overflowing the token count.
Other designs are equally valid. Floating-point tokens, as in golang.org/x/time/rate, or a representation based on when the next token becomes due, both pass if the candidate can explain their rounding and boundaries. The lab replays all six scenarios through rate.Limiter.AllowN with the same explicit times, and both implementations give the same answer at every step. The contract is ordinary token-bucket behaviour, not a quirk invented for the interview.
A rubric that rewards reasoning, tests and trade-offs
Score each area from 1 to 4 immediately after the session, and write evidence beside every score: a quoted explanation, a test name, a moment in Recent changes or a hint you gave. A 4 means the candidate showed the behaviour without prompting and explained it; a 3 means it was shown with a gap the candidate noticed or repaired; a 2 means it appeared only after a hint; a 1 means it did not appear.
- Understanding the contract. Restates the rules in their own words, asks about units and the clock before typing, and identifies rule 4 as the subtle one.
- Correctness through tests. Runs Test after each meaningful change and reads failures accurately. A complete pass is not required for a high score when the remaining failure is understood and the planned fix is right.
- Invariants and edge cases. Explains why partial progress must survive, what happens while the bucket is full, why a backwards clock must not add tokens and what an extremely long gap does.
- Concurrency reasoning. Holds one lock across the whole read-modify-write. Explains why a green browser run cannot show that the locking is correct, and what
go test -raceadds, without claiming that the race detector proves the absence of races. Its documentation is explicit that it finds only races in code paths that actually run. - Testing judgement. Proposes or writes a test for a follow-up case and explains how it would fail for the old bug.
- Trade-offs and communication. Compares whole tokens with floating-point tokens, mentions when a maintained package is the better choice, explains decisions as they go and changes course when the evidence says so.
Write down what does not score, and share it with every interviewer. Typing speed, remembering exact signatures, compiler errors the candidate fixes, a different valid representation, the number of helper functions, accent and fluency, and unfamiliarity with the Playground's buttons all carry no penalty. Looking things up on pkg.go.dev is allowed and should be said aloud at the start.
Follow-up questions that change one assumption
Good follow-ups change one assumption and ask what breaks. They show how a candidate transfers understanding, which matters more than whether the first implementation was perfect.
Start with the gap the tests leave on purpose: what happens with a one-nanosecond interval after an extremely long idle period? In the lab, an implementation that adds the earned tokens first and clamps afterwards passes all six scenarios and the concurrency test, but fails this test that a candidate might add:
// Follow-up: "What happens after a very long idle period?"
func TestHugeGapDoesNotOverflow(t *testing.T) {
clock := newFakeClock()
l, err := NewLimiter(time.Nanosecond, 3, clock.Now)
if err != nil {
t.Fatal(err)
}
l.Allow()
l.Allow() // one token left
clock.Advance(time.Duration(math.MaxInt64))
for i := range 3 {
if !l.Allow() {
t.Fatalf("call %d after the gap was denied", i)
}
}
if l.Allow() {
t.Fatal("a fourth call was allowed; the bucket exceeded burst")
}
}Credit a candidate who finds the overflow and writes the test. Never treat its absence from the first implementation as a failure; it was not in the contract.
Other follow-ups that work well with this task; several have worked answers in the interview library:
- Limit per client. A map of limiters grows with every new key. How is it bounded, and when is an idle entry removed? The LRU cache guide is a useful comparison. Ask what the key should be; the forged forwarded address guide shows why a client-supplied header is a poor identity.
- Wait instead of reject. How would a
Wait(ctx)method stop waiting when its context is cancelled, and what happens to a token it had already reserved? See cancellation is not joining. Theratepackage offersReserveandWaitfor comparison. - Three replicas. Three local limiters allow three times the intended rate. What would a shared limit cost in latency and failure handling? The rate-limited job platform guide widens that conversation.
- Real timers in tests. How would you test a waiting limiter without sleeps? Our synctest guide covers fake time for goroutines.
- Build or depend. When would you use
golang.org/x/time/rateinstead, and what would you check before adopting it?
Remove unfairness you did not intend
Hidden requirements are the most common unfairness, and the easiest to remove. If a behaviour affects the score, it is either in the contract with a test, or it is a follow-up discussed openly. Do not change the requirements halfway through unless you say so explicitly and adjust the time.
Trivia is the next problem. Asking for the exact signature of a library function, or the order of fields in a standard type, tests memory of documentation that working engineers keep open. Say at the start that pkg.go.dev is allowed, and mean it. In the same spirit, the starting file supplies the constructor and the type, so nobody is judged on how fast they type boilerplate. If a candidate asks you to type a mechanical change they have dictated, do it; the change history will show your name on it, and the reasoning remains theirs.
Decide the policy on AI assistants before the call and tell the candidate in the invitation. If assistance is allowed, the candidate should still be able to explain every line; if it is not, say so plainly. The interview ethics guide describes how candidates can discuss assisted work honestly. If you allow an agent in the room through the GopherForge MCP companion, remember that the agent's host and model provider can read the decrypted source it is given.
Prepare a hint ladder and use it consistently: first point at the failing test's name, then ask a question about the rule, and only then suggest an approach. Record each hint as evidence for one rubric area rather than as a general penalty. Use the same task, the same hints and the same follow-ups for every candidate at a level. Score straight after the call, before a later candidate can reshape your memory of an earlier one.
Finally, separate environment problems from engineering. If the browser fails, switch to the fallback and do not count the lost minutes against the candidate.
Accessibility and pacing
Ask every candidate the same question in the invitation: is there anything about the format we should adjust? Then describe the format precisely, including the language, the tool, the length, whether talking aloud is expected and whether a second interviewer will watch. Offering an equivalent practice task in the Playground lets candidates try the editor, the Test button and the room before the day. If you choose to send the real task in advance, send it to every candidate.
The Playground has some controls that help: adjustable editor font size, line wrapping, Find with Ctrl/⌘ + F, a keyboard shortcut for Run and labelled panels for Output, Input, Problems, Debug and Packages, plus a separate Share panel. On a narrow screen, the file list opens over the editor and closes when you pick a file. We did not audit the Playground with assistive technologies for this guide, so do not promise that it suits everyone. Offer alternatives: the candidate can work in their own editor while sharing a screen and paste into the room at checkpoints, receive extra time, take breaks or write their reasoning instead of speaking it. Turn on captions in the video call if the candidate wants them, and read test output aloud when asked.
A 60-minute plan that fits inside the room's lifetime:
- 5 minutes: introductions, the rules on tools and hints, create the room and check that both people can edit.
- 5 minutes: the candidate reads the contract and the tests and asks questions.
- 30 minutes: implementation, test runs and, if useful, a debug session.
- 10 minutes: follow-up questions.
- 10 minutes: the candidate's own questions, then export and close the room.
Create the room at the start of the call rather than earlier, and export the final source before the last ten minutes, in case the room ends early.
Privacy, links and what to keep afterwards
The encryption key travels in the fragment of the room link, the part after #. RFC 3986 specifies that a fragment is separated from the rest of the URI before the resource is retrieved, and the Playground keeps the key there, so it is not sent to the relay. The Playground encrypts source changes, output and cursor presence with AES-256-GCM before they reach the relay. The relay sees encrypted packets, room and role identifiers, sizes, timing and ordinary network metadata. The site still serves the browser code, so this protects room content at the relay; it does not protect against a malicious replacement website or a compromised participant.
Treat a complete room link as a credential. Anyone who holds it has that role until the room expires or the owner closes it. Anything you paste it into, such as a chat log, an email thread, a calendar invitation or an applicant-tracking note, keeps the full link, fragment included. Send the Edit link directly to the candidate, keep the View link within the panel, never paste either into a shared channel, and press Close the room in the creating tab when the interview ends.
Decide what to keep before the call and tell the candidate in the invitation:
- Keep: the final source from Export ZIP, the text of the last test run, the task version, the rubric scores with their evidence, and the hints you gave.
- Offer the candidate: a copy of their own final source.
- Do not keep: the room link, which is useless after closure and dangerous before it, or recordings the candidate has not agreed to.
Retain records only as long as your hiring policy and local law allow. Local recovery drafts remain in ordinary browser storage on each participant's device; they are not an encrypted backup. Interviewers using a shared computer should export what they need and clear the site's data afterwards. A one-hour room is a meeting place, not an archive.
Primary sources & editorial method
We checked these primary references on 30 November 2026. Release facts are attributed; recommended workflows and examples are GopherForge analysis. Illustrations are conceptual, not vendor screenshots or benchmarks; the one figure labelled as a screenshot is a capture of this site.
- golang.org/x/time/rate package documentation (v0.16.0)
- Go time package: monotonic clocks
- Go sync package: Mutex and WaitGroup.Go
- Go data race detector
- Go release history: Go 1.27.1 and Go 1.27.3
- Go command documentation: build constraints
- RFC 3986 section 3.5: fragment
- Yjs shared-editing framework
- GopherForge guide: encrypted rooms and the MCP companion
