Standard library / log/slog

slog.Any()

Construct a keyed Any attribute for structured logging. Expected stdout: 'key\n42\n'.

Formal Syntax & Structure

go syntaxgo
func Any(key string, value any) Attr

Parameters & Attributes

NameTypeDescription
keystringAttribute key.
valueanyInput to the operation as described above.

Return Value

Attr

Construct a keyed Any attribute for structured logging.

Working Example

Example Snippetgo
package main
import (  "fmt"  "log/slog")
func main() { a := slog.Any("key", 42); fmt.Println(a.Key); fmt.Println(a.Value) }
Go Reference