GopherCon Europe 2025 in Berlin featured sessions on modern identifier strategies for Go microservices, with UUID v7 adoption following the May 2024 publication of RFC 9562. The conference brought together Go engineers from companies running large PostgreSQL and CockroachDB deployments, with shared experience on B-tree fragmentation from UUID v4 primary keys. See UUID in Go for the implementation reference.

Key topics covered

google/uuid v7 adoption — The release of uuid.New7() in google/uuid v1.6.0 aligned with RFC 9562 ratification. Sessions demonstrated that migrating from uuid.New() (v4) to uuid.New7() (v7) is a one-line change:

import "github.com/google/uuid"

// Before
id := uuid.New()        // UUID v4 — random

// After
id := uuid.New7()       // UUID v7 — time-sortable, RFC 9562 compliant

No column type change is needed — both are 128-bit UUIDs stored identically in PostgreSQL’s uuid type. See UUID in Go for GORM and pgx integration patterns.

GORM UUID v7 primary key

// models/order.go
package models

import (
    "github.com/google/uuid"
    "gorm.io/gorm"
)

type Order struct {
    ID       uuid.UUID `gorm:"type:uuid;primaryKey"`
    Status   string
    CustomerID uuid.UUID `gorm:"type:uuid"`
}

func (o *Order) BeforeCreate(tx *gorm.DB) error {
    if o.ID == uuid.Nil {
        id, err := uuid.NewV7()
        if err != nil { return err }
        o.ID = id
    }
    return nil
}

The BeforeCreate hook assigns UUID v7 before every INSERT, equivalent to the TypeORM @BeforeInsert() pattern. See UUID in Databases for how the timestamp-prefixed key affects PostgreSQL B-tree page fill rates.

pgx — raw PostgreSQL driver

import (
    "context"
    "github.com/google/uuid"
    "github.com/jackc/pgx/v5/pgxpool"
)

func createOrder(ctx context.Context, pool *pgxpool.Pool, customerID uuid.UUID) (uuid.UUID, error) {
    id, err := uuid.NewV7()
    if err != nil { return uuid.Nil, err }

    _, err = pool.Exec(ctx,
        `INSERT INTO orders (id, customer_id) VALUES ($1, $2)`,
        id, customerID,
    )
    return id, err
}

pgx v5 natively encodes uuid.UUID values for PostgreSQL’s uuid column type — no manual hex conversion needed.

Distributed ID generation across Go services

Sessions at GopherCon EU 2025 also addressed multi-node UUID v7 generation. Because UUID v7 uses per-process random bits in rand_b, two goroutines on different machines generating a UUID in the same millisecond will produce distinct values with overwhelming probability. The monotonic counter (RFC 9562 §6.2 Method 1) ensures strict ordering within a single process during high-throughput bursts. See UUID v7 in Distributed Systems for the multi-node collision analysis.

Further reading

External references

Frequently asked questions

What UUID v7 Go libraries were discussed at GopherCon EU 2025?

Sessions at GopherCon EU 2025 covered the google/uuid package (v1.6+ adds uuid.New7()), the gofrs/uuid package, and GORM's UUID primary key pattern. The consensus recommendation was google/uuid for new projects targeting RFC 9562 compliance. See UUID in Go — full guide.

How does UUID v7 compare to Go's default UUID practices before RFC 9562?

Before RFC 9562 (May 2024), Go projects almost universally used UUID v4 via uuid.New(). UUID v7 — available since google/uuid v1.6.0 via uuid.New7() — adds a 48-bit millisecond timestamp prefix that enables lexicographic sort order matching creation time. This matters for GORM/PostgreSQL models where ORDER BY id now implies chronological order. See UUID v4 vs v7 and GopherCon 2024 UUID talk.