GopherCon 2025 in Chicago was a landmark for UUID adoption in the Go community. With google/uuid v1.6+ shipping NewV7() and PostgreSQL 18 adding native gen_random_uuid_v7(), Go engineers arrived ready to migrate production services from UUID v4 to v7. See UUID in Go for the practical guide.
Event details
| Conference | GopherCon 2025 |
| Date | July 7–10, 2025 |
| Location | Chicago, IL, USA |
| Focus | UUID v7 in the Go ecosystem — google/uuid, pgx, GORM, and distributed tracing |
Key sessions
UUID v7 as the default ID type in Go services
The headline talk argued that UUID v4 should be replaced with UUID v7 as the default identifier for new Go services. Key points:
uuid.NewV7()is a drop-in replacement foruuid.New()with better database locality- UUID v7’s 48-bit timestamp prefix eliminates the need for a
created_atcolumn in time-ordered queries - The monotonic counter in UUID v7 (12 rand_a bits) prevents clock-skew collisions — see UUID v7 and Clock Skew
- Migration from UUID v4: new records use v7; old records are read-compatible
google/uuid API walkthrough
import "github.com/google/uuid"
// Generate UUID v7 (requires google/uuid v1.6+)
id, err := uuid.NewV7()
if err != nil {
log.Fatal(err)
}
fmt.Println(id.String()) // 018fbe3a-4c5d-7b12-8f3e-1a2b3c4d5e6f
// Extract creation timestamp
ts, _ := uuid.TimestampFromV7(id)
t, _ := ts.Time()
fmt.Println(t) // 2026-10-18 13:00:00.123 +0000 UTC
// Version and variant check
fmt.Println(id.Version()) // 7
fmt.Println(id.Variant()) // RFC4122 (same as RFC 9562)
// Parse from string
parsed, _ := uuid.Parse("018fbe3a-4c5d-7b12-8f3e-1a2b3c4d5e6f")
fmt.Println(parsed.Version()) // 7
PostgreSQL with pgx and UUID v7
import (
"context"
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgxpool"
)
type Order struct {
ID string
CustomerID string
Total float64
}
func createOrder(ctx context.Context, pool *pgxpool.Pool, customerID string, total float64) (string, error) {
id, err := uuid.NewV7()
if err != nil {
return "", err
}
_, err = pool.Exec(ctx,
`INSERT INTO orders (id, customer_id, total) VALUES ($1, $2, $3)`,
id.String(), customerID, total,
)
return id.String(), err
}
// Cursor pagination: UUID v7 lexicographic = chronological
func listOrders(ctx context.Context, pool *pgxpool.Pool, cursor string, limit int) ([]Order, string, error) {
var rows pgx.Rows
var err error
if cursor != "" {
rows, err = pool.Query(ctx,
`SELECT id, customer_id, total FROM orders WHERE id > $1 ORDER BY id LIMIT $2`,
cursor, limit,
)
} else {
rows, err = pool.Query(ctx,
`SELECT id, customer_id, total FROM orders ORDER BY id LIMIT $1`,
limit,
)
}
if err != nil {
return nil, "", err
}
defer rows.Close()
var orders []Order
for rows.Next() {
var o Order
rows.Scan(&o.ID, &o.CustomerID, &o.Total)
orders = append(orders, o)
}
nextCursor := ""
if len(orders) == limit {
nextCursor = orders[len(orders)-1].ID
}
return orders, nextCursor, nil
}
See UUID v7 for Cursor Pagination for the full pattern.
UUID v7 trace IDs in context
type contextKey struct{}
// Attach UUID v7 trace ID to context at request ingress
func withTraceID(ctx context.Context) (context.Context, string) {
id, _ := uuid.NewV7()
traceID := id.String()
return context.WithValue(ctx, contextKey{}, traceID), traceID
}
// Retrieve trace ID from any downstream function
func traceIDFrom(ctx context.Context) string {
if id, ok := ctx.Value(contextKey{}).(string); ok {
return id
}
return ""
}
// net/http middleware
func traceMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx, traceID := withTraceID(r.Context())
w.Header().Set("X-Trace-ID", traceID)
next.ServeHTTP(w, r.WithContext(ctx))
})
}
See UUID v7 in Microservices for distributed tracing patterns.
GORM with UUID v7
import (
"gorm.io/gorm"
"github.com/google/uuid"
)
type Product struct {
ID string `gorm:"type:uuid;primaryKey"`
Name string
Price float64
}
func (p *Product) BeforeCreate(tx *gorm.DB) error {
if p.ID == "" {
id, err := uuid.NewV7()
if err != nil {
return err
}
p.ID = id.String()
}
return nil
}
See UUID v7 in Go Fiber for the complete Fiber + GORM integration.
Conference takeaways
- UUID v7 is production-ready in Go — google/uuid v1.6+ ships it; no external dependencies needed
- Replace
uuid.New()withuuid.NewV7()— the API surface is identical - Drop
created_atfor time ordering — UUID v7 timestamp prefix suffices for ORDER BY - Context propagation is the right trace ID pattern — use
context.WithValue, not HTTP headers alone - PostgreSQL 18
gen_random_uuid_v7()— eliminates application-side ID generation for DB-generated keys
Further reading
- UUID in Go — google/uuid Package Guide
- UUID v7 in Go Fiber — HTTP API Patterns
- UUID v7 in Microservices — Trace IDs and Correlation
- UUID v7 for Cursor Pagination
- GopherCon EU 2025 — UUID v7 in Go Services
External references
Frequently asked questions
What UUID v7 topics were covered at GopherCon 2025?
GopherCon 2025 sessions explored UUID v7 adoption in the Go ecosystem: the google/uuid package's NewV7() API, using UUID v7 as PostgreSQL primary keys with pgx and GORM, embedding UUID v7 trace IDs in Go's context.Context, and migrating from UUID v4 in production services. The monotonic counter in UUID v7 was highlighted as a solution for high-throughput generators. See UUID in Go.
How does google/uuid support UUID v7 in Go?
The google/uuid package added uuid.NewV7() in v1.6.0 (2024). It returns a UUID v7 with a 48-bit Unix millisecond timestamp and 74 random bits. The package is concurrency-safe. Use uuid.TimestampFromV7(id) to extract the creation timestamp from a UUID v7 value. See UUID in Go.
How do you embed UUID v7 trace IDs in Go context?
Define a context key type and use context.WithValue: ctx = context.WithValue(ctx, traceKey{}, id.String()). Downstream functions retrieve it with ctx.Value(traceKey{}).(string). Pass the context through your handler chain — Fiber, net/http, and gRPC all support context propagation. UUID v7's timestamp prefix lets you recover request timing from logs without a separate timestamp field.