← All notes

Go container/ring: operations on circular lists

Answer: The ring package implements operations on circular lists.

The Ring type

A Ring is an element of a circular list, or ring.

New returns a ring of n elements.

Rings do not have a beginning or end.

Empty rings are represented as nil Ring pointers.

The zero value is a one-element ring whose Value is nil.

Common operations

A pointer to any element serves as reference to the entire ring.

Next and Prev walk the list.

Move steps n % len elements, and Len reports the number of elements.

Link connects one ring with another, and Unlink removes elements from the ring.

Do calls a function on every value in the ring.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, container/ring package reference; The Go Authors, container/ring source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, container/ring package reference; The Go Authors, container/ring source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.

Cite this

Permanent ID: iil:note:70x5bvmc

iinventedlight. 2026. "Go container/ring: operations on circular lists." iinventedlight Library, iil:note:70x5bvmc, version of 2026-11-24. https://iinventedlight.com/library/notes/go-container-ring/. License: CC-BY-4.0.

@misc{iil_note_70x5bvmc,
  author = {{iinventedlight}},
  title = {{Go container/ring: operations on circular lists}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-24},
  url = {https://iinventedlight.com/library/notes/go-container-ring/},
  note = {Permanent ID iil:note:70x5bvmc. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-container-ring.md.