---
source: https://iinventedlight.com/library/notes/go-select-statement.md
title: "Go select: waiting on multiple channel operations"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (Go project); CC-BY-4.0 (Go project); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Go project, Effective Go, Channels; Go project, The Go Programming Language Specification, Select statements. CC-BY-4.0 (https://go.dev/copyright). Copyright The Go Authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-select-statement"
tags: [go, select, channels, concurrency, systems]
client: Librarian
sources:
  - id: S1
    title: "Effective Go, Channels"
    publisher: Go project
    url: https://go.dev/doc/effective_go#channels
    accessed: 2026-11-23
    license: "CC-BY-4.0"
  - id: S2
    title: "The Go Programming Language Specification, Select statements"
    publisher: Go project
    url: https://go.dev/ref/spec#Select_statements
    accessed: 2026-11-23
    license: "CC-BY-4.0"
---
# Go select: waiting on multiple channel operations
**Answer:** A select statement chooses among a set of possible send or receive operations. If none can proceed and there is no default case, it blocks until one can.

## What the spec requires

It looks similar to a switch statement, but the cases all refer to communication operations.

At most one default case is allowed, and it may appear anywhere in the list of cases.

When several communications can proceed, one of them is chosen by uniform pseudo-random selection.

Otherwise, if there is a default case, that case is chosen. Without a default, select blocks until at least one communication can proceed.

## A default case in practice

Effective Go shows a client that keeps a free list and uses a buffered channel to represent that list.

If the channel is empty, a new buffer gets allocated. The example uses a default case in select to do that.

The server loop returns the buffer to the free list.

## See also

- [go-goroutines](https://iinventedlight.com/library/notes/go-goroutines/)
- [go-channels](https://iinventedlight.com/library/notes/go-channels/)
- [go-testing](https://iinventedlight.com/library/notes/go-testing/)

## Claims

- id: C1
  claim: select chooses which of a set of possible send or receive operations will proceed.
  source: S2
  evidence: "chooses which of a set of possible"

- id: C2
  claim: There can be at most one default case.
  source: S2
  evidence: "There can be at most one default case"

- id: C3
  claim: With no default case, select blocks until a communication can proceed.
  source: S2
  evidence: "the \"select\" statement blocks until"

- id: C4
  claim: Effective Go uses select with a default case to allocate a buffer when a free list is empty.
  source: S1
  evidence: "If the channel is empty, a new buffer gets allocated"

## Sources

- [S1] Effective Go, Channels. Go project. https://go.dev/doc/effective_go#channels . License: CC-BY-4.0. Accessed 2026-11-23.

- [S2] The Go Programming Language Specification, Select statements. Go project. https://go.dev/ref/spec#Select_statements . License: CC-BY-4.0. Accessed 2026-11-23.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go project, Effective Go, Channels; Go project, The Go Programming Language Specification, Select statements. CC-BY-4.0 (https://go.dev/copyright). Copyright The Go Authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
