Table of Contents

Golang Live Coding Exam (Junior → Middle)

This exam evaluates fundamental Go skills, basic concurrency, and clean coding.

Time suggestion: 45–60 minutes

Test 1: Sum of Integers

Question

Write a function that receives a list of integers and returns their sum.

Input

[1, 2, 3, 4, 5]

Output

15

Constraints

Do not use external libraries

Must handle empty slices

Evaluation Criteria

Correct result

Clean and readable code

Proper function signature

Notes

Slice /slaɪs/: dynamic array in Go

Test 2: Word Frequency Counter

Question

Given a string, count how many times each word appears.

Words are separated by spaces.

Input

"go is fun and go is fast"

Output

go: 2
is: 2
fun: 1
and: 1
fast: 1

Constraints

Case-sensitive

Use built-in data structures only

Evaluation Criteria

Correct map usage

Proper string manipulation

Clean iteration logic

Notes

Map /mæp/: key-value data structure

Iteration /ˌɪtəˈreɪʃən/: looping over data

Test 3: Filter Even Numbers

Question

Write a function that returns only even numbers from a list.

Input

[1, 2, 3, 4, 5, 6]

Output

[2, 4, 6]

Constraints

Maintain input order

No global variables

Evaluation Criteria

Correct condition logic

Proper slice handling

Notes

Even number /ˈiːvən ˈnʌmbər/: number divisible by 2

Test 4: Goroutine with Channel

Question

Create a goroutine that sends numbers from 1 to 3 into a channel. The main function must receive and print them.

Input

1, 2, 3

Output

1
2
3

Constraints

Must use one goroutine

Channel must be closed properly

Evaluation Criteria

Correct goroutine usage

Proper channel closing

No deadlocks

Notes

Goroutine /ˌɡoʊˈruːtiːn/: lightweight concurrent function

Deadlock /ˈdɛdˌlɒk/: program waits forever

Test 5: Simple HTTP Handler

Question

Create an HTTP server that:

Listens on port 8080

Responds “Hello Go” to /hello

Input

GET /hello

Output

Hello Go

Constraints

Use net/http

No third-party libraries

Evaluation Criteria

Correct handler implementation

Proper server startup

Clean code structure

Notes

HTTP handler /ˌeɪtʃ tiː tiː piː ˈhændlər/: function handling HTTP requests

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