Skip to main content
Go Container is a Go module that provides minimal, high-performance implementations of common data structures using Go generics. Every type is fully type-safe, with multiple backing storage implementations so you can tune for your workload.

Quick Start

Install the module and write your first type-safe container in minutes.

OrderedMap

A map that preserves insertion order, with optional LRU recency mode.

Queue & WaitableQueue

Classic and concurrency-safe queues with flow-control watermarks.

Set

Idiomatic Go sets with union, intersection, and difference operations.

Stack

LIFO stack with multiple backing implementations.

Choosing an Implementation

Pick the right backing store for your performance requirements.

Get started in three steps

1

Install the module

Add github.com/fgm/container to your Go module.
go get github.com/fgm/container
2

Import and use a data structure

Choose the type you need and create an instance with a size hint.
import "github.com/fgm/container/queue"

q := queue.NewSliceQueue[int](100)
q.Enqueue(42)
v, ok := q.Dequeue() // v=42, ok=true
3

Explore the reference

Browse the Data Structures section to learn every method and option available.
All implementations except WaitableQueue are not concurrency-safe. If you need a queue safe for use across goroutines, see WaitableQueue.