---
title: "Index expression special cases for maps"
url: https://daily.dev/posts/index-expression-special-cases-for-maps-ycsun7sv4
source_url: https://boldlygo.tech/archive/2023-11-17-index-expression-special-cases-for-maps
type: article
source: "Boldly Go"
published: 2026-05-31T07:49:22.318Z
updated: 2026-05-31T09:10:50.744Z
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.

# Index expression special cases for maps

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

## Summary

A focused look at two special cases for map index expressions in Go. First, the two-value assignment form (v, ok := a[x]) returns an additional boolean indicating whether a key exists, which helps distinguish between a missing key and a key explicitly set to the zero value. Second, while reading from a nil map is valid and returns the zero value, assigning to a nil map causes a runtime panic. Code examples illustrate both behaviors clearly.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://boldlygo.tech/archive/2023-11-17-index-expression-special-cases-for-maps>

## Similar posts on daily.dev

- [Exploiting Zero Values in Maps](https://daily.dev/posts/exploiting-zero-values-in-maps-4nfi6z0h7) · Go monk · 0 upvotes · 0 comments

---

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

[View this post on daily.dev](https://daily.dev/posts/index-expression-special-cases-for-maps-ycsun7sv4)
