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