Standard library / log/slog
slog.DurationValue()
Construct an unkeyed Duration value for use in an attribute. Expected stdout: '2s\n'.
Formal Syntax & Structure
go syntaxgo
func DurationValue(v time.Duration) ValueParameters & Attributes
| Name | Type | Description |
|---|---|---|
| v | time.Duration | Values to log or convert. |
Return Value
Value
Construct an unkeyed Duration value for use in an attribute.
Working Example
Example Snippetgo
package main
import ( "fmt" "log/slog" "time")
func main() { fmt.Println(slog.DurationValue(2 * time.Second)) }