Standard library / log/slog

slog.Int()

Construct a keyed Int attribute for structured logging. Expected stdout: 'key\n2\n'.

Formal Syntax & Structure

go syntaxgo
func Int(key string, value int) Attr

Parameters & Attributes

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

Return Value

Attr

Construct a keyed Int attribute for structured logging.

Working Example

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