Standard library / log/slog

slog.Float64()

Construct a keyed Float64 attribute for structured logging. Expected stdout: 'key\n1.5\n'.

Formal Syntax & Structure

go syntaxgo
func Float64(key string, v float64) Attr

Parameters & Attributes

NameTypeDescription
keystringAttribute key.
vfloat64Values to log or convert.

Return Value

Attr

Construct a keyed Float64 attribute for structured logging.

Working Example

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