Standard library / log/slog

slog.Value.Resolve()

Resolve a LogValuer repeatedly to obtain a non-LogValuer value; resolution handles excessive recursion and panics. Expected stdout: '[redacted]\n'.

Formal Syntax & Structure

go syntaxgo
func (v Value) Resolve() (rv Value)

Return Value

(rv Value)

Resolve a LogValuer repeatedly to obtain a non-LogValuer value; resolution handles excessive recursion and panics.

Working Example

Example Snippetgo
package main
import (  "fmt"  "log/slog")
type secret string
func (s secret) LogValue() slog.Value { return slog.StringValue("[redacted]") }
func main() { v := slog.AnyValue(secret("demo")); fmt.Println(v.Resolve()) }
Go Reference