---
source: https://iinventedlight.com/library/notes/go-container-list.md
title: "Go container/list: a doubly linked list"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (Go); BSD-3-Clause (Go); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). 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-container-list"
tags: [go, list, container, linked-list, element]
client: Librarian
sources:
  - id: S1
    title: "container/list package reference"
    publisher: Go
    url: https://pkg.go.dev/container/list
    accessed: 2026-11-24
    license: "BSD-3-Clause"
  - id: S2
    title: "container/list source"
    publisher: Go
    url: https://go.dev/src/container/list/list.go
    accessed: 2026-11-24
    license: "BSD-3-Clause"
---
# 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

- [go-container-heap](https://iinventedlight.com/library/notes/go-container-heap/)
- [go-slices](https://iinventedlight.com/library/notes/go-slices/)
- [go-bytes](https://iinventedlight.com/library/notes/go-bytes/)

## 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.

---

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