record

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package record provides internal utilities for safe manipulation of slog.Record values.

This package is internal and not intended for use by external consumers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneRecord

func CloneRecord(r slog.Record) slog.Record

CloneRecord creates an attribute-materializing clone of a slog.Record that is safe for use across goroutine boundaries.

The standard slog.Record stores attributes via an iterator function that may reference stack-allocated memory. When a record needs to be processed asynchronously (e.g., sent through a channel to a background worker) or fanned out to multiple handlers, all attributes must be "materialized" — copied to heap-allocated storage — to prevent use-after-return bugs.

The cloned record preserves:

  • Timestamp (Time)
  • Level
  • Message
  • Source location (PC)
  • All attributes (including nested groups)

Note: this is NOT a reflection-based deep copy. Attribute values of type slog.AnyValue that contain pointers, maps, or slices are copied by reference. If callers store mutable values in attributes, they must ensure those values are not mutated after the log call.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL