Git blame may be helpful, and specifically commit 847d40d6998. It looks like code drifted from the comment.

-eli 

On May 24, 2024, at 9:25 AM, Jochen Voss <jochen.v...@gmail.com> wrote:

Hello,

In the Go standard library, in the file log/slog/handler.go, I found the following code:

func (h *commonHandler) clone() *commonHandler {
// We can't use assignment because we can't copy the mutex.
return &commonHandler{
json:              h.json,
opts:              h.opts,
preformattedAttrs: slices.Clip(h.preformattedAttrs),
groupPrefix:       h.groupPrefix,
groups:            slices.Clip(h.groups),
nOpenGroups:       h.nOpenGroups,
w:                 h.w,
mu:                h.mu, // mutex shared among all clones of this handler
}
}

The first comment states that "we can't copy the mutex", but then the last line seems to copy the mutex anyway.  What is going on here?

Maybe this just an oversight from a time when every hander had its own mutex?  Or is there something subtle going on here?

Many thanks,
Jochen

--
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/153e9898-f17e-44cc-ab2a-8570f916c0c3n%40googlegroups.com.

--
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/D370602F-6226-4AAC-B3EC-6BA164FEA4F9%40siliconsprawl.com.

Reply via email to