Standard library / log/slog
slog.Level.UnmarshalText()
Parse a textual severity level. Expected stdout: 'DEBUG\n'.
Formal Syntax & Structure
go syntaxgo
func (l *Level) UnmarshalText(data []byte) errorParameters & Attributes
| Name | Type | Description |
|---|---|---|
| data | []byte | Input to the operation as described above. |
Return Value
error
Parse a textual severity level.
Working Example
Example Snippetgo
package main
import ( "fmt" "log/slog")
func check(e error) { if e != nil { panic(e) }}
func main() { var l slog.Level; check(l.UnmarshalText([]byte("DEBUG"))); fmt.Println(l) }