This is an old revision of the document!
Table of Contents
Senior Golang Live Coding Exam
This exam contains 5 live coding tests for Senior Golang developers. Candidates are expected to write correct, concurrent-safe, idiomatic Go code.
Time suggestion: 60–90 minutes
Test 1: Worker Pool Processing
Question
You are given a list of jobs represented by integers. Create a worker pool with N workers that processes the jobs concurrently.
Each job must:
Sleep for 100ms
Return jobID * 2
The program must print the result for each job.
Input
jobs = [1, 2, 3, 4, 5]
workers = 2
Output
Order does NOT matter.
2 4 6 8 10
Constraints
Must use goroutines and channels
Must not have data races
Workers must exit cleanly
Evaluation Criteria
Correct concurrency model
No race conditions
Clean shutdown logic
Notes
Worker pool /ˈwɜːrkər puːl/: group of workers processing tasks
Data race /ˈdeɪtə reɪs/: unsafe concurrent memory access
Test 2: Rate Limiter
Question
Implement a rate limiter that allows at most 2 requests per second.
Each call to Allow() returns:
true if the request is allowed
false otherwise
Input
Call times (milliseconds):
0ms 200ms 400ms 600ms 800ms
Output
true true false false false
Constraints
Must be safe for concurrent use
Must rely on time-based logic
Busy-waiting is not allowed
Evaluation Criteria
Correct rate limiting
Thread-safe implementation
Efficient time handling
Notes
Rate limiter /reɪt ˈlɪmɪtər/: controls request frequency
Busy-waiting /ˈbɪzi ˈweɪtɪŋ/: wasting CPU while waiting
Test 3: Concurrent URL Fetcher
Question
Write a function that fetches multiple URLs concurrently, but limits concurrency.
Input
URLs:
https://example.com/a https://example.com/b https://example.com/c
Max concurrency = 2
Output
success: https://example.com/a success: https://example.com/b success: https://example.com/c
(Order does NOT matter)
Constraints
At most 2 HTTP requests at the same time
Must wait for all requests to finish
Errors must not crash the program
Evaluation Criteria
Correct concurrency limit
Proper error handling
No goroutine leaks
Notes
Concurrency limit /kənˈkʌrənsi ˈlɪmɪt/: maximum parallel tasks
Goroutine leak /ˌɡoʊˈruːtiːn liːk/: goroutine that never exits
Test 4: Thread-Safe Cache with TTL
Question
Implement an in-memory cache with expiration support.
Each key:
Has a value
Expires after TTL (seconds)
Input
Set("a", 1, ttl=1s)
Get("a") -> after 500ms
Get("a") -> after 1500ms
Output
1 nil
Constraints
Concurrent access must be safe
Expired keys must not be returned
No global variables
Evaluation Criteria
Correct TTL handling
Proper locking strategy
Clean code structure
Notes
TTL (Time To Live) /ˌtiː tiː ˈɛl/: duration data is valid
Thread-safe /θred seɪf/: safe for concurrent use
Test 5: Graceful HTTP Server Shutdown
Question
Create an HTTP server that:
Listens on port 8080
Responds “OK” to /health
Shuts down gracefully on SIGINT
Input
HTTP request: GET /health
OS signal: SIGINT
Output
OK Server shutdown completed
Constraints
In-flight requests must complete
Shutdown timeout must be handled
No forced exit (os.Exit)
Evaluation Criteria
Proper signal handling
Correct use of http.Server.Shutdown
Clean resource release
Notes
Graceful shutdown /ˈɡreɪsfəl ˈʃʌtdaʊn/: stopping without interrupting work
In-flight request /ɪn flaɪt rɪˈkwɛst/: request being processed
