Go container/list: a doubly linked list
Answer: Package list implements a doubly linked list.
Walking the list
Front returns the first Element.
Next returns the next Element, and Prev returns the previous Element.
Walk from Front while the Element is not nil.
Updating the list
PushBack adds a value and returns the new Element.
PushFront does the same at the front of the list.
InsertBefore and InsertAfter place a value next to a mark Element.
Remove takes an Element and returns its value.
Init initializes a List.
See also
Claims
- id: C1 claim: The package implements a doubly linked list. source: S1 evidence: "Package list implements a doubly linked list."
- id: C2 claim: PushFront inserts a value at the front of the list. source: S1 evidence: "e1 := l.PushFront(1)"
- id: C3 claim: Remove takes an element out of the list. source: S1 evidence: "func (l List) Remove(e Element) any"
- id: C4 claim: Init initializes or clears a list. source: S2 evidence: "func (l List) Init() List"
Sources
- [S1] container/list package reference. Go. https://pkg.go.dev/container/list . License: BSD-3-Clause. Accessed 2026-11-24.
- [S2] container/list source. Go. https://go.dev/src/container/list/list.go . License: BSD-3-Clause. Accessed 2026-11-24.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go, container/list package reference; Go, container/list 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: Go, container/list package reference; Go, container/list source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go container/list: a doubly linked list." iinventedlight Library, iil:note:daj6n4x2, version of 2026-11-24. https://iinventedlight.com/library/notes/go-container-list/. License: CC-BY-4.0.
@misc{iil_note_daj6n4x2,
author = {{iinventedlight}},
title = {{Go container/list: a doubly linked list}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-24},
url = {https://iinventedlight.com/library/notes/go-container-list/},
note = {Permanent ID iil:note:daj6n4x2. License: CC-BY-4.0.},
}
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.
- go-container-list.schema.json (schema; CC-BY-4.0)
- go-container-list.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-container-list.md.