We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6090e87 + 5b03062 commit 45b2a33Copy full SHA for 45b2a33
v2/attrs.go
@@ -32,6 +32,11 @@ func Hex2(key string, value []byte) slog.Attr {
32
// HexN is a convenience function for hex-encoded log attributes which prints
33
// a maximum of n bytes.
34
func HexN(key string, value []byte, n uint) slog.Attr {
35
+ // Handle nil slice gracefully.
36
+ if value == nil {
37
+ return slog.String(key, "<nil>")
38
+ }
39
+
40
if len(value) <= int(n) {
41
return slog.String(key, hex.EncodeToString(value))
42
}
0 commit comments