Unsynchronized map access
Review this Go in-memory cache used by HTTP handlers.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 25 min
Mark a line and say what kind of problem it is.0 findings
1type Cache struct {
2 data map[string][]byte
3}
4
5func NewCache() *Cache { return &Cache{data: map[string][]byte{}} }
6
7func (c *Cache) Get(k string) ([]byte, bool) {
8 v, ok := c.data[k]
9 return v, ok
10}
11
12func (c *Cache) Set(k string, v []byte) {
13 c.data[k] = v
14}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.