Closed denpeshkov closed 2 hours ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
this looks working as intended for slog, the issue is in your code
Thanks for your reply! Just to confirm, do I need to handle nil values explicitly even if the method receiver is defined on a value rather than a pointer?
Even without accessing struct fields, I'm encountering a panic: https://go.dev/play/p/vott61McxDf?v=gotip
given a pointer, Go needs to dereference it to pass to the method. That's where your nil pointer dereference is coming from. It also panics if you call f.LogValue()
directly, without slog.
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
For questions please refer to https://github.com/golang/go/wiki/Questions
Go version
go1.23 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
Go Playground link
What did you see happen?
2009/11/10 23:00:00 INFO Message text foo="LogValue panicked\ncalled from runtime.panicwrap (/usr/local/go-faketime/src/runtime/error.go:355)\ncalled from main.(foo).LogValue (:1)\ncalled from log/slog.Value.Resolve (/usr/local/go-faketime/src/log/slog/value.go:512)\ncalled from log/slog.( handleState).appendAttr (/usr/local/go-faketime/src/log/slog/handler.go:468)\ncalled from log/slog.(*handleState).appendNonBuiltIns.func1 (/usr/local/go-faketime/src/log/slog/handler.go:342)\n(rest of stack elided)\n"
What did you expect to see?
2009/11/10 23:00:00 INFO Message text foo=