---
title: "Context value key collisions"
url: https://daily.dev/posts/context-value-key-collisions-z3juz811k
source_url: https://boldlygo.tech/archive/2025-05-23-context-value-key-collisions
type: article
source: "Boldly Go"
published: 2026-05-31T07:49:17.400Z
updated: 2026-05-31T09:16:14.298Z
tags: ["golang"]
reading_time: 2
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Context value key collisions

**[Boldly Go](https://daily.dev/sources/boldlygo)** · 2 min read · 0 upvotes · 0 comments

## Summary

When multiple packages store values in Go's context using the same string key (e.g., "user"), a key collision occurs. If one package sets a context value and another package retrieves it expecting a different type, the type assertion fails silently. The Go documentation recommends using unexported types as context keys to prevent this cross-package collision problem.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://boldlygo.tech/archive/2025-05-23-context-value-key-collisions>

---

Tags: [#golang](https://daily.dev/tags/golang)

[View this post on daily.dev](https://daily.dev/posts/context-value-key-collisions-z3juz811k)
