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) AttrParameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | string | Attribute key. |
| value | any | Input 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) }