Go debugging exercises
Go's simplicity is intentional, but its concurrent runtime has sharp corners: assigning to a nil map panics immediately, unbuffered channels deadlock if nobody is listening, and passing a struct with a value receiver quietly drops mutations.
These exercises train you to spot and fix real Go defects: from slice capacity and pointer receivers to WaitGroup race conditions and goroutine channel coordination.
Practise by topic
How to debug a Go function
- Read the panic message carefully. Go's runtime panics pinpoint the exact file, line, and goroutine stack trace.
- Check pointer vs value receivers. If a method does not mutate the struct as expected, check whether the receiver is (c *Counter) or (c Counter).
- Trace channel buffers and closing semantics. An unbuffered channel requires an active receiver in another goroutine; closing a closed channel panics immediately.
- Check slice length vs capacity. Appending beyond capacity reallocates the underlying array, discarding mutations in callers if the slice header was not returned.
- Verify goroutine closures. In loops before Go 1.22, range loop variables must be passed as arguments or re-scoped inside the iteration.
The exercises
Easy
- Panic on assignment to uninitialized nil mapNull and undefined
- Value receiver fails to mutate struct stateType
- Slice bounds out of range panic on short stringLogic
- Integer division truncates rate calculationType
- Float comparison without epsilon delta toleranceLogic
- Time format layout error using standard dateMutation and copying
- Incorrect capacity passed to make slice functionLogic
Medium
- Unexpected behavior when appending to a Go sliceLogic
- Unexpected output in concurrent range loop processingAsync and race conditions
- Unexpected behavior with nil interface comparisonNull and undefined
- Unexpected Result from Resource Cleanup in Go FunctionAsync and race conditions
- Stalled Goroutine: Data Not Received as ExpectedAsync and race conditions
- Map Panic on AssignmentNull and undefined
- Error handling issue in Go function with shadowed variableScope and closure
- Goroutines finish before expected despite using sync.WaitGroupAsync and race conditions
- Increasing memory usage in periodic task schedulerLogic
- Zero-length slice copy in data transferLogic
- JSON Unmarshal fails to populate struct fields silentlyType
- Consistent Panic on Concurrent Atomic Value UpdateAsync and race conditions
- Worker function not exiting properly causing timeoutsAsync and race conditions
- Unexpected character index in multi-byte UTF-8 stringType
- Unexpected stale data appears in slice processingLogic
- Increment method fails to update struct value as expectedType
- Consistent Panic in Channel HandlingAsync and race conditions
- Panic during channel operation in concurrent Go programAsync and race conditions
- Unexpected zero value in concurrent Go programAsync and race conditions
- Concurrent access to mutex in struct causes data raceAsync and race conditions
- Unpredictable behavior in concurrent message handlingAsync and race conditions
- Unexpected TCP socket connection leak in HTTP clientLogic
- Random sequence repeats identically across multiple runsMutation and copying
- Panic on interface type assertion in GoType
- Custom error type returning non-nil error on nil interfaceNull and undefined
- UTF-8 multi-byte rune indexing errorType
- Deadlock on unbuffered channel without receiverAsync and race conditions
- Deadlock in range loop over unclosed channelInfinite loops
- Interface nil comparison bug with typed nilNull and undefined
- JSON Unmarshal silent failure with lowercase fieldsLogic
- Panic on closing already closed Go channelAsync and race conditions
- Negative modulo index out of range in hash bucketLogic
- WaitGroup Add inside goroutine creates race conditionAsync and race conditions
- Shadowed variable inside if statement blockScope and closure
- Slice append mutation drops across function callLogic
- Loop variable captured by reference in goroutineAsync and race conditions
- Defer evaluation timing with variable assignmentScope and closure
- Truncating multi-byte string by raw byte sliceLogic
- Sort Slice comparator violates strict weak orderingLogic
- Missing mutex unlock on early error returnAsync and race conditions
- Select default branch starves channel communicationAsync and race conditions
What you will practise
Questions
Do I need to install the Go compiler?
No. All Go exercises execute and verify tests directly through BugHunt without requiring any local toolchain installation.
Which Go version is targeted?
Modern Go 1.22+ semantics, including standard library packages sync, context, time, and math/rand.
Is there a certificate?
Yes, free. Solving Go challenges earns LinkedIn-verified debugging credentials.