Standard library / log/slog
slog.String()
Construct a keyed String attribute for structured logging. Expected stdout: 'key\ngo\n'.
Formal Syntax & Structure
go syntaxgo
func String(key, value string) AttrParameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | string | Attribute key. |
| value | string | Input to the operation as described above. |
Return Value
Attr
Construct a keyed String attribute for structured logging.
Working Example
Example Snippetgo
package main
import ( "fmt" "log/slog")
func main() { a := slog.String("key", "go"); fmt.Println(a.Key); fmt.Println(a.Value) }