The behavior of that nil check may have changed last week 
in https://github.com/golang/go/commit/548158c4a57580e8c8bd0e9b2f91d03b31efa879 
. Maybe because dloggerFake is a struct{} rather than a *struct{}?

I wouldn't bother with the nil check. I'd chain the methods like 
dlog().s("foo").i(42).end() and never (or, nearly never) keep a reference 
to an active dlogger.

The debug logger doesn't print anything on normal exits—only when the 
program crashes. That's what Michael P meant in the issue update you linked 
by "The buffer will be dumped on throw." I'm not sure how severely the 
program has to crash in order to trigger that printing. It should 
definitely work with runtime.throw. Maybe also with a normal un-recovered 
panic, or possibly also with os.Exit(1).
On Tuesday, August 6, 2024 at 6:10:34 AM UTC-7 Leah Stapleton wrote:

> I'm trying to debug a problem in the go runtime and wished to use the 
> debuglog.go features found in 
> https://github.com/golang/go/blob/master/src/runtime/debuglog.go
>
> However,  when I follow the example here 
> https://github.com/golang/go/issues/59600#issuecomment-1515040287 
>
> d := dlog() if d != nil { d.s("foo") d.i(42) d.end() }
>
> I can't build the Go source code
>
> Building Go cmd/dist using /usr/local/go (go1.22.0 darwin/amd64)
> Building Go toolchain1 using /usr/local/go
> Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1
>
> *Invalid operation d != nil mismatched types (dlogger and untyped nil)*
>
> I changed the code to remove the *d != nil *check, and was able to build 
> the go source code, but when I build my app with this go source code using 
> the *-tags debuglog*
>
> bin/go build -tags debuglog -o myapp *.go
>
> it is not printing any debug logs to my terminal
>
> Can any suggest anything?
>
> Thank you
>   
>
> invalid operation: d != nil (mismatched types dlogger and untyped nil)
>
> Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64)
>
> Building Go toolchain1 using /usr/local/go.
>
> Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
>
> Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64)
>
> Building Go toolchain1 using /usr/local/go.
>
> Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
>
> Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64)
>
> Building Go toolchain1 using /usr/local/go.
>
> Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
>
> Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64)
>
> Building Go toolchain1 using /usr/local/go.
>
> Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
>
> Building Go cmd/dist using /usr/local/go. (go1.22.0 darwin/amd64)
>
> Building Go toolchain1 using /usr/local/go.
>
> Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
>
> Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
>
>  invalid operation: d != nil (mismatched types dlogger and untyped nil)
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/fd289b84-acb7-419b-b908-78bc4d885c0fn%40googlegroups.com.

Reply via email to