Description
Go Programming Experience
Intermediate
Other Languages Experience
Go, JS
Has this idea, or one like it, been proposed before?
No
Does this affect error handling?
No
Is this about generics?
No
Proposal
Introduce the following data structures, designed to be used similarly to Go’s built-in maps that improves performance.
LinkedList[T] — A linked list supporting standard operations such as PushFront, PushBack, PopFront, PopBack, Front, Back, etc.
Stack[T] — A stack implementation that uses a singly linked list, with the top of the stack at the head of the list.
Queue[T] — A queue implementation that uses a linked list, where elements are enqueued at the tail and dequeued from the head.
These structures should be created in a way similar to how maps are initialized in Go.
When Marshaling these data structures into a json they should be an array without popping from original.
Language Spec Changes
Go’s built-in map doesn’t provide methods like Push or Get. But for handling data structures like linked lists, Go needs to support method functions. Without method support, you wouldn’t be able to implement operations like Push, Pop, or Enqueue in a clean and structured way.
Informal Change
Data structures LinkedList[T], Stack[T], Queue[T] that feel like Go's map, so you can initialize them like this:
stack := makeStack[int]()
queue := makeQueue[string]()
li := makeLinkedList[float64]()
Is this change backward compatible?
Yes
Orthogonality: How does this change interact or overlap with existing features?
Operations like pushing/popping or enqueuing/dequeuing are O(1), unlike slices that may need shifting or reallocation under the hood.
These structures don’t reallocate memory like slices do, so they’re more stable under heavy usage or real-time systems. Plus, they’re type-safe.
Would this change make Go easier or harder to learn, and why?
No response
Cost Description
No response
Changes to Go ToolChain
vet, gopls, gofmt
Performance Costs
These data structure require more resources then slices and arrays. But cost effective and fast in larger scale.
Prototype
They should look like this when implementing.
li := make(LinkedList[T])
stack := make(Stack[T])
queue := make(Queue[T])